View Source Varu64 (Varu64 v0.2.0)
Simple variable-length encoding of U64
Link to this section Summary
Link to this section Functions
Specs
decode(binary()) :: {non_neg_integer(), binary()} | :error
Decode a Varu64 at the head of a binary
Returns a {u64, rest_of_binary} tuple on success :error on failure. Will fail on noncanonical representations
Examples
iex> Varu64.decode(<<0>>)
{0, ""}
iex> Varu64.decode(<<248, 255, 72, 105>>)
{255, "Hi"}
Specs
encode(non_neg_integer()) :: binary() | :error
Encode to Varu64 format
Examples
iex> Varu64.encode(0)
<<0>>
iex> Varu64.encode(18446744073709551615)
<<255, 255, 255, 255, 255, 255, 255, 255, 255>>