thrifty/varint
Values
pub fn decode_varint(
data: BitArray,
byte_position: Int,
) -> Result(#(Int, Int), types.DecodeError)
Decode a varint from a BitArray starting at a given byte position. Returns Ok(#(value, next_byte_position)) on success, or Error on failure.
Max length: 10 bytes for i64, 5 bytes for i32. Reads bytes LSB first, accumulating 7-bit groups.
pub fn encode_varint(n: Int) -> BitArray
Encode an unsigned integer as a varint BitArray. Returns a BitArray of 1-10 bytes (for i64).
Varint encoding: 7 bits per byte, MSB as continuation bit. Bytes are emitted LSB first.
Panics if n is negative. Use callers that guarantee non-negative input
(e.g. ZigZag-encode signed integers before calling this function).