ProtoRune. Varint
(proto_rune v0.5.1)
Copy Markdown
Unsigned LEB128 variable-length integer encoding.
Used internally to read CAR files and CID values from the ATProto event stream, where lengths and codec identifiers are varint-prefixed.
Summary
Functions
Encodes a non-negative integer as a varint.
Reads a varint from the head of the given binary.
Functions
@spec encode(non_neg_integer()) :: binary()
Encodes a non-negative integer as a varint.
@spec read(binary()) :: {:ok, non_neg_integer(), binary()} | {:error, atom()}
Reads a varint from the head of the given binary.
Returns the decoded integer along with the unconsumed rest of the input.