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
nil nil
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

format_type()

format_type() = jsx | jiffy | map

msgpack_ext_packer()

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

msgpack_ext_unpacker()

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

msgpack_list_options()

msgpack_list_options() = [{format, format_type()} | jsx | jiffy | {allow_atom, none | pack} | {enable_str, boolean()} | {ext, {msgpack_ext_packer(), msgpack_ext_unpacker()} | module()}]

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_term()

msgpack_term() = [msgpack_term()] | msgpack_map() | integer() | float() | boolean() | binary()

object()

object() = msgpack_term()

options()

options() = msgpack_list_options()

Function Index

binary_to_term/1
binary_to_term/2
pack/1Encode an erlang term into an msgpack binary.
pack/2
term_to_binary/1
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, {badarg, 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()

term_to_binary/1

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

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()}}

unpack_stream/2

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


Generated by EDoc, Jul 29 2022, 16:26:31.