Skip to content

MessagePack Implementation for Elixir / msgpack.org[Elixir]

Notifications You must be signed in to change notification settings

Kaizen-Gaming/msgpack-elixir

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MessagePack for Elixir

Build Status

Installation

Add :message_pack as a dependency in your mix.exs file.

defp deps do
  [{:message_pack, "~> 0.2.0"}]
end

Usage

# pack
MessagePack.pack([1,2,3]) #=> { :ok, <<147,1,2,3>> }
MessagePack.pack!([1,2,3]) #=> <<147,1,2,3>>

{:ok, iolist, encoded_byte_size} = MessagePack.pack_iodata([1,2,3]) #=> {:ok, [<<147>>, [<<1>>, <<2>>, <<3>>]], 4}
{iolist, encoded_byte_size} = MessagePack.pack_iodata!([1,2,3]) #=> {[<<147>>, [<<1>>, <<2>>, <<3>>]], 4}

# unpack
MessagePack.unpack(<<147,1,2,3>>) #=> { :ok, [1,2,3] }
MessagePack.unpack!(<<147,1,2,3>>) #=> [1,2,3]

# unpack_once
MessagePack.unpack_once(<<147,1,2,3,4>>) #=> {:ok, {[1, 2, 3], <<4>>}}
MessagePack.unpack_once!(<<147,1,2,3,4>>) #=> {[1, 2, 3], <<4>>}

Options

  • enable_string

Support string type. This options is false by default.

iex(1)> { :ok, bin } = MessagePack.pack(<<255>>)
{:ok, <<161, 255>>}
iex(3)> MessagePack.unpack(<<161, 255>>)
{:ok, <<255>>}
iex(4)> MessagePack.unpack(<<161, 255>>, enable_string: true)
{:error, {:invalid_string, <<255>>}}
  • ext

Support extention type.

See test/message_pack_ext_test.exs.

License

MIT

About

MessagePack Implementation for Elixir / msgpack.org[Elixir]

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Elixir 100.0%