mirror of
https://github.com/valitydev/msgpack-erlang.git
synced 2024-11-06 08:45:19 +00:00
commit
8aefe346da
@ -54,8 +54,8 @@ erlang- native types like `pid()`, `ref()` contained in `tuple()`. See
|
|||||||
`test/msgpack_ext_example_tests.erl` for example code.
|
`test/msgpack_ext_example_tests.erl` for example code.
|
||||||
|
|
||||||
```erlang
|
```erlang
|
||||||
Packer = fun({ref, Ref}, Opt) when is_ref(Ref) -> {ok, {12, term_to_binary(Ref)}} end,
|
Packer = fun({ref, Ref}, Opt) when is_reference(Ref) -> {ok, {12, term_to_binary(Ref)}} end,
|
||||||
Unpacker = fun(12, Bin) -> {ok, {ref, binary_to_term(Ref)}},
|
Unpacker = fun(12, Bin) -> {ok, {ref, binary_to_term(Bin)}} end,
|
||||||
Ref = make_ref(),
|
Ref = make_ref(),
|
||||||
Opt = [{ext,{Packer,Unpacker}}],
|
Opt = [{ext,{Packer,Unpacker}}],
|
||||||
{ok, {ref, Ref}} = msgpack:unpack(msgpack:pack({ref, Ref}, Opt), Opt).
|
{ok, {ref, Ref}} = msgpack:unpack(msgpack:pack({ref, Ref}, Opt), Opt).
|
||||||
|
Loading…
Reference in New Issue
Block a user