std.leb128
7-bit varints (wasm, dwarf, protobuf); padded forms ok, >64 bits fails
LebError
Section titled “LebError”pub LebError :: errors { buffer_too_small, truncated, overflow,}buffer_too_small:outtoo small; nothing writtentruncated: the bytes end in the middle of a numberoverflow: more than 64 bits
MAX_LEN
Section titled “MAX_LEN”pub MAX_LEN :: 10usizemax bytes for a 64-bit value
Unsigned
Section titled “Unsigned”pub Unsigned :: struct { value: u64, len: usize,}decoded value + bytes used
Signed
Section titled “Signed”pub Signed :: struct { value: i64, len: usize,}len_u64
Section titled “len_u64”pub len_u64 :: fn(v: u64) -> usizeencoded size of v
len_i64
Section titled “len_i64”pub len_i64 :: fn(v: i64) -> usizeencoded size of v, signed
encode_u64
Section titled “encode_u64”pub encode_u64 :: fn(out: []u8, v: u64) -> usize ! LebErrorencode v into out; returns len_u64(v)
encode_i64
Section titled “encode_i64”pub encode_i64 :: fn(out: []u8, v: i64) -> usize ! LebErrorencode signed v into out; returns len_i64(v)
decode_u64
Section titled “decode_u64”pub decode_u64 :: fn(bytes: []const u8) -> Unsigned ! LebErrordecode from the start of bytes
decode_i64
Section titled “decode_i64”pub decode_i64 :: fn(bytes: []const u8) -> Signed ! LebErrordecode signed from the start of bytes