marshal

Binary Serialization

Constants

MARSHAL_NIL    = 0
MARSHAL_I64    = 1
MARSHAL_STR    = 2
MARSHAL_ARRAY  = 3
MARSHAL_MAP    = 4

Functions

FunctionDescription
_msh_copy
_msh_write32Internal: write 4-byte LE integer.
_msh_read32Internal: read 4-byte LE integer.
_msh_write64Internal: write 8-byte LE integer.
_msh_read64Internal: read 8-byte LE integer.
marshal_nilWrite nil. Returns new offset.
marshal_i64Write i64 value. Returns new offset.
marshal_strWrite string. Returns new offset.
marshal_array_beginWrite array header (type tag + count). Returns new offset. Caller must then w…
marshal_map_beginWrite map header (type tag + pair count). Returns new offset. Caller must the…
unmarshal_typePeek type tag at offset.
unmarshal_i64Read i64 value (skips type tag). Returns the value.
unmarshal_str_lenRead string length at offset.
unmarshal_strRead string. Copies to out. Returns new offset (past string).
unmarshal_array_countGet array count at offset.
unmarshal_skipSkip one marshaled value. Returns new offset.

Details

_msh_copy

fn _msh_copy(dst: &i8, doff: i64, src: &i8, soff: i64, n: i64)

_msh_write32

fn _msh_write32(buf: &i8, off: i64, val: i64) -> i64

Internal: write 4-byte LE integer.

_msh_read32

fn _msh_read32(buf: &i8, off: i64) -> i64

Internal: read 4-byte LE integer.

_msh_write64

fn _msh_write64(buf: &i8, off: i64, val: i64) -> i64

Internal: write 8-byte LE integer.

_msh_read64

fn _msh_read64(buf: &i8, off: i64) -> i64

Internal: read 8-byte LE integer.

marshal_nil

fn marshal_nil(buf: &i8, off: i64) -> i64

Write nil. Returns new offset.

marshal_i64

fn marshal_i64(buf: &i8, off: i64, val: i64) -> i64

Write i64 value. Returns new offset.

marshal_str

fn marshal_str(buf: &i8, off: i64, s: &i8, slen: i64) -> i64

Write string. Returns new offset.

marshal_array_begin

fn marshal_array_begin(buf: &i8, off: i64, count: i64) -> i64

Write array header (type tag + count). Returns new offset. Caller must then write count elements.

marshal_map_begin

fn marshal_map_begin(buf: &i8, off: i64, count: i64) -> i64

Write map header (type tag + pair count). Returns new offset. Caller must then write count key-value pairs.

unmarshal_type

fn unmarshal_type(buf: &i8, off: i64) -> i64

Peek type tag at offset.

unmarshal_i64

fn unmarshal_i64(buf: &i8, off: i64) -> i64

Read i64 value (skips type tag). Returns the value.

unmarshal_str_len

fn unmarshal_str_len(buf: &i8, off: i64) -> i64

Read string length at offset.

unmarshal_str

fn unmarshal_str(buf: &i8, off: i64, out: &i8) -> i64

Read string. Copies to out. Returns new offset (past string).

unmarshal_array_count

fn unmarshal_array_count(buf: &i8, off: i64) -> i64

Get array count at offset.

unmarshal_skip

fn unmarshal_skip(buf: &i8, off: i64) -> i64

Skip one marshaled value. Returns new offset.