2014-09-19 21:45:44 +03:00
|
|
|
-- Buildat: extension/cereal/init.lua
|
|
|
|
local polybox = require("buildat/extension/polycode_sandbox")
|
|
|
|
local log = buildat.Logger("extension/cereal")
|
|
|
|
local M = {safe = {}}
|
|
|
|
|
|
|
|
function M.safe.binary_input(data, types)
|
2014-09-19 23:08:09 +03:00
|
|
|
if type(data) ~= 'string' then
|
|
|
|
error("data not string")
|
|
|
|
end
|
|
|
|
if type(types) ~= 'table' then
|
|
|
|
error("types not table")
|
|
|
|
end
|
2014-09-19 21:45:44 +03:00
|
|
|
return __buildat_cereal_binary_input(data, types)
|
|
|
|
end
|
|
|
|
|
2014-09-19 23:08:09 +03:00
|
|
|
function M.safe.binary_output(values, types)
|
|
|
|
if type(values) ~= 'table' then
|
|
|
|
error("values not table")
|
|
|
|
end
|
|
|
|
if type(types) ~= 'table' then
|
|
|
|
error("types not table")
|
|
|
|
end
|
|
|
|
if #values ~= #types then
|
|
|
|
error("values and types must have the same length")
|
|
|
|
end
|
|
|
|
return __buildat_cereal_binary_output(values, types)
|
|
|
|
end
|
|
|
|
|
2014-09-19 21:45:44 +03:00
|
|
|
return M
|