Skip to main content

Module vint

Module vint 

Source
Expand description

EBML variable-length integer (VINT) decode — RFC 8794 (docs/standards/registry.toml id rfc-8794-ebml).

A VINT’s first byte encodes its total length L (1..=8) as a unary prefix: the position of the leading 1 bit (VINT_MARKER) counted from the most significant bit gives L. Every bit after the marker — the rest of the first byte plus all following bytes — is VINT_DATA (7*L bits).

Two decodes share this shape but differ in what counts as “the value”:

  • Element size (decode_size): the marker is stripped; an all-1s VINT_DATA is the reserved “unknown size” sentinel (VintSize::unknown).
  • Element ID (decode_id): the marker bit is kept — the ID is the raw L bytes read as a big-endian integer (RFC 8794 §7).

These are public, low-level, and usable standalone (probe/debug tooling), per the workspace “low-level APIs stay first-class” rule.

Structs§

VintSize
Decoded element size VINT (marker stripped).

Functions§

decode_id
Decode an element ID VINT at the start of buf (marker bits kept).
decode_size
Decode an element size VINT at the start of buf (marker stripped).
encode_id
Encode an element ID (marker bits already included, matching decode_id’s raw representation) into out, using the minimal byte length that holds the value without a leading zero byte.
encode_size
Encode an element size VINT (marker stripped from value, marker bit added on write) into out.
encode_unknown_size
Write the reserved “unknown size” VINT of length len (1..=8) into out — all VINT_DATA bits set to 1, marker bit set.