Velocy v0.1.3 Velocy View Source
An Elixir parser and generator for VelocyPack v1.
Large majority of the code is taken from https://github.com/ArangoDB-Community/velocy_pack.
The implementation is heavily inspired by Jason and borrows some code (specifically the Codegen module).
Examples
iex> {:ok, vpack} = Velocy.encode(10.2312514)
{:ok, <<27, 245, 78, 96, 149, 102, 118, 36, 64>>}
iex> Velocy.decode(vpack)
{:ok, 10.2312514}
iex> vpack = Velocy.encode!(%{a: "a", b: %{bool: true, float: 10.2312514}})
<<11, 37, 2, 65, 97, 65, 97, 65, 98, 11, 26, 2, 68, 98, 111, 111, 108, 26, 69, 102, 108, 111, 97, 116, 27, 245, 78, 96, 149, 102, 118, 36, 64, 3, 9, 3, 7>>
iex> Velocy.decode!(vpack)
%{"a" => "a", "b" => %{"bool" => true, "float" => 10.2312514}}
iex> Velocy.decode(<<11>>)
{:error, %Velocy.Error{message: "unexpected sequence", dump: nil}}
iex> Velocy.decode!(<<11>>)
** (Velocy.Error) unexpected sequence
iex> Velocy.decode(<<11, 823891328731>>)
{:error, %Velocy.Error{message: "unexpected byte", dump: "0xdb"}}
iex> Velocy.decode!(<<11, 823891328731>>)
** (Velocy.Error) unexpected byte: 0xdb
Link to this section Summary
Functions
Parses the the first VelocyPack value from a binary or iodata.
Parses the the first VelocyPack value from a binary or iodata.
Generates a VelocyPack value as a binary corresponding to term
.
Generates a VelocyPack value as a binary corresponding to term
.
Link to this section Types
Link to this section Functions
Parses the the first VelocyPack value from a binary or iodata.
The options parameter is reserved for future use and not used at the moment.
Parses the the first VelocyPack value from a binary or iodata.
Same as decode/2
except it will unwrap the tuple and raise
in case of errors.
Generates a VelocyPack value as a binary corresponding to term
.
The generation is controlled by the Velocy.Encoder
protocol,
please refer to the module to read more on how to define the protocol
for custom data types.
The options parameter is reserved for future use and not used at the moment.
Generates a VelocyPack value as a binary corresponding to term
.
Same as encode/2
except it will unwrap the tuple and raise
in case of errors.