Module msgpack

MessagePack codec for Erlang.

Description

MessagePack codec for Erlang.

APIs are almost compatible with C API except for buffering functions (both copying and zero-copying), which are unavailable.

Equivalence between Erlang and Msgpack type :
erlang msgpack
integer() pos_fixnum/neg_fixnum/uint8/uint16/uint32/uint64/int8/int16/int32/int64
float() float/double
null null
boolean() boolean
binary() fix_raw/raw16/raw32
list() fix_array/array16/array32
{proplist()} fix_map/map16/map32
[{term(),term{}]|[{}] fix_map/map16/map32
map() fix_map/map16/map32

Data Types

ext_packer()

ext_packer() = fun((tuple(), msgpack:options()) -> {ok, {Type::byte(), Data::binary()}} | {error, any()})

ext_unpacker()

ext_unpacker() = fun((byte(), binary(), msgpack:options()) -> {ok, msgpack_term()} | {error, any()}) | fun((byte(), binary()) -> {ok, msgpack_term()} | {error, any()})

format_type()

format_type() = jsx | jiffy | map

msgpack_map()

msgpack_map() = msgpack_map_jsx() | msgpack_map_jiffy() | map()

msgpack_map_jiffy()

msgpack_map_jiffy() = {[{msgpack_term(), msgpack_term()}]}

msgpack_map_jsx()

msgpack_map_jsx() = [{msgpack_term(), msgpack_term()}] | [{}]

msgpack_map_unpacker()

msgpack_map_unpacker() = fun((binary(), non_neg_integer(), msgpack:opt_record()) -> {msgpack_map(), binary()} | no_return())

msgpack_term()

msgpack_term() = [msgpack_term()] | msgpack_map() | integer() | float() | boolean() | binary() | string() | {string, string()}

object()

object() = msgpack_term()

opt_record()

opt_record() = #options_v4{spec = new | old, allow_atom = none | pack, known_atoms = [atom() | binary()], unpack_str = as_binary | as_list | as_tagged_list, use_nil = boolean(), validate_string = boolean(), pack_str = from_binary | from_list | from_tagged_list | none, map_format = format_type(), map_unpack_fun = msgpack_map_unpacker(), ext_packer = msgpack:ext_packer() | undefined, ext_unpacker = msgpack:ext_unpacker() | undefined, original_list = msgpack:options()}

options()

options() = [{spec, new | old} | {allow_atom, none | pack} | {known_atoms, [atom()]} | {unpack_str, as_binary | as_list | as_tagged_list} | {use_nil, boolean()} | {validate_string, boolean()} | {pack_str, from_binary | from_list | from_tagged_list | none} | {map_format, map | jiffy | jsx} | {ext, {msgpack:ext_packer(), msgpack:ext_unpacker()} | module()}]

Function Index

binary_to_term/1
binary_to_term/2
pack/1Encode an erlang term into an msgpack binary.
pack/2
term_to_binary/1ext_packer that packs only tuples with length > 2.
unpack/1Decode an msgpack binary into an erlang terms.
unpack/2
unpack_stream/1
unpack_stream/2

Function Details

binary_to_term/1

binary_to_term(Bin::binary()) -> term()

binary_to_term/2

binary_to_term(Bin::binary(), Opt::[safe]) -> term()

pack/1

pack(Term::msgpack:object()) -> binary() | {error, term()}

Encode an erlang term into an msgpack binary. Returns {error, {badarg, term()}} if the input is illegal.

pack/2

pack(Term::msgpack:object(), Opts::msgpack:options()) -> binary() | {error, term()}

term_to_binary/1

term_to_binary(Term::term()) -> binary()

ext_packer that packs only tuples with length > 2

unpack/1

unpack(Bin::binary()) -> {ok, msgpack:object()} | {error, not_just_binary} | {error, incomplete} | {error, {badarg, term()}}

Decode an msgpack binary into an erlang terms. It only decodes ONLY ONE msgpack packets contained in the binary. No packets should not remain. Returns {error, {badarg, term()}} if the input is corrupted. Returns {error, incomplete} if the input is not a full msgpack packet (caller should gather more data and try again).

unpack/2

unpack(Bin::binary(), Opts::msgpack:options()) -> {ok, msgpack:object()} | {error, any()}

unpack_stream/1

unpack_stream(Bin::binary()) -> {msgpack:object(), binary()} | {error, incomplete} | {error, {badarg, term()}} | {error, any()}

unpack_stream/2

unpack_stream(Bin::binary(), Opts0::msgpack:options()) -> {msgpack:object(), binary()} | {error, incomplete} | {error, {badarg, term()}} | {error, any()}


Generated by EDoc, May 31 2024, 14:08:52.