Skip to main content

Module coding

Module coding 

Source
Expand description

Variable-length integers (RFC 9000 §16) and a bounds-checked reader.

Structs§

Reader
A cursor over a byte slice; every read is bounds-checked.

Constants§

VARINT_MAX
Largest value a varint can hold (2^62 - 1).

Functions§

get_varint
Decodes a single varint from the front of buf.
put_varint
Appends v as a varint. Panics in debug builds when v exceeds VARINT_MAX.
put_varint_fixed
Writes v as a varint of exactly len bytes (used for patched length fields).
varint_len
Encoded size of v in bytes (1, 2, 4 or 8). v must be at most VARINT_MAX.