Simple type-length-value. Type and length are encoded as Varu64
Summary
Functions
@spec decode(binary()) :: {non_neg_integer(), binary(), binary()} | :error
Decode arbitrary binary in stlv form.
Returns {type, value, rest_of_binary} on success.
Examples
iex> Stlv.decode(<<249, 1, 0, 4, 240, 159, 146, 169, 77, 111, 114, 101>>)
{256, "💩", "More"}
@spec encode(binary(), non_neg_integer()) :: binary()
Encode arbitrary binary in stlv form.
Examples
iex> Stlv.encode("💩", 256)
<<249, 1, 0, 4, 240, 159, 146, 169>>