Skip to main content

Module varint

Module varint 

Source
Expand description

Unsigned LEB128 varint encoding.

A varint encodes an unsigned integer in one to ten bytes. The low seven bits of each byte carry payload, and the top bit signals continuation: 1 means more bytes follow, 0 means the value is complete.

The encoding is identical to the format used by Protocol Buffers, WebAssembly, and DWARF.

Constants§

MAX_LEN_U16
Maximum encoded length of a u16 varint.
MAX_LEN_U32
Maximum encoded length of a u32 varint.
MAX_LEN_U64
Maximum encoded length of a u64 varint.

Functions§

decode_u32
Decode a u32 varint from buf.
decode_u64
Decode a u64 varint from buf.
encode_u32
Encode value as a u32 varint into buf.
encode_u64
Encode value as a u64 varint into buf.
encoded_len_u32
Encoded length of value as a u32 varint, in bytes (1 to 5).
encoded_len_u64
Encoded length of value as a u64 varint, in bytes (1 to 10).