DASL.DRISL
(dasl v0.1.0)
View Source
DRISL (Deterministic Representation for Interoperable Structures & Links).
A deterministic CBOR profile with native support for CIDs as links. Delegates
to DASL.DRISL.Decoder and DASL.DRISL.Encoder for the actual work.
Summary
Functions
Decodes a DRISL-encoded binary into an Elixir term.
Encodes an Elixir term into a DRISL-compliant CBOR binary.
Functions
Decodes a DRISL-encoded binary into an Elixir term.
CBOR tag 42 values are decoded into %DASL.CID{} structs. Returns
{:ok, term, rest} on success, or {:error, reason} on failure.
Examples
iex> DASL.DRISL.decode(<<0xa1, 0x61, 0x61, 0x01>>)
{:ok, %{"a" => 1}, ""}
iex> DASL.DRISL.decode(<<0x83, 0x01, 0x02, 0x03>>)
{:ok, [1, 2, 3], ""}
Encodes an Elixir term into a DRISL-compliant CBOR binary.
Returns {:ok, binary} on success, or {:error, reason} on failure.
Examples
iex> DASL.DRISL.encode(%{"a" => 1})
{:ok, <<0xa1, 0x61, 0x61, 0x01>>}
iex> DASL.DRISL.encode([1, 2, 3])
{:ok, <<0x83, 0x01, 0x02, 0x03>>}
iex> DASL.DRISL.encode(true)
{:ok, <<0xf5>>}