Varint v1.2.0 Varint.LEB128 View Source
This module provides functions to work with LEB128 encoded integers.
Link to this section Summary
Link to this section Functions
Decodes LEB128 encoded bytes to an unsigned integer.
Returns a tuple where the first element is the decoded value and the second element the bytes which have not been parsed.
iex> Varint.LEB128.decode(<<172, 2>>)
{300, <<>>}
iex> Varint.LEB128.decode(<<172, 2, 0>>)
{300, <<0>>}
iex> Varint.LEB128.decode(<<0>>)
{0, <<>>}
iex> Varint.LEB128.decode(<<1>>)
{1, <<>>}
Encodes an unsigned integer using LEB128 compression.
iex> Varint.LEB128.encode(300)
<<172, 2>>
iex> Varint.LEB128.encode(0)
<<0>>
iex> Varint.LEB128.encode(1)
<<1>>