README.md

# Velocy

An Elixir parser and generator for [VelocyPack](https://github.com/arangodb/velocypack/blob/master/VelocyPack.md) v1.

Large majority of the code is taken from https://github.com/ArangoDB-Community/velocy_pack.

The implementation is heavily inspired by [Jason](https://github.com/michalmuskala/jason) and
borrows some code (specifically the Codegen module).

## Examples

```elixir
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
```