Skip to main content

encode_size

Function encode_size 

Source
pub fn encode_size(value: u64, out: &mut Vec<u8>)
Expand description

Encode an element size VINT (marker stripped from value, marker bit added on write) into out.

Uses the minimal byte length L (1..=8) that fits value in 7*L data bits. The all-1s VINT_DATA pattern is reserved for “unknown size” (decode_size), so a value that would exactly fill all-1s bumps to the next length.

Never panics: a value that doesn’t fit even 8 bytes’ worth of VINT data (56 bits — not reachable for any size this crate itself ever writes, but push_frame’s caller-supplied track_number is technically unbounded) saturates to the largest representable 8-byte value rather than crashing.