ptwm_core
ptwm_core::varint
Unsigned LEB128 varints and a bounds-checked byte cursor for the compact wire formats (the \x89PTWS frame and the compact chain wire).
ptwm_core::varint
Unsigned LEB128 varints and a bounds-checked byte cursor for the compact wire formats (the \x89PTWS frame and the compact chain wire).
ptwm_core::varint
crates/ptwm-core/src/varint.rs:1mod varintUnsigned LEB128 varints and a bounds-checked byte cursor for the compact wire formats (the `\x89PTWS` frame and the compact chain wire).
Parsing is canonical: a varint must use the fewest bytes that hold its
value (no trailing `0x80`/`0x00` groups), is at most 10 bytes long, and
must fit in `u64`, so each value has one varint encoding. The compact
formats build on this: each of their fields has one encoding for the
value it holds. (A compact frame as a whole still leaves the writer some
choices; see [`crate::compact`].)
ptwm_core::varint::Cursor
crates/ptwm-core/src/varint.rs:78pub struct CursorA bounds-checked reader over one wire section. Every error is an [`PtwmCoreError::InvalidContainer`] prefixed with the cursor's context (for example `"compact frame"`).
ptwm_core::varint::MAX_VARINT_LEN
crates/ptwm-core/src/varint.rs:14pub const MAX_VARINT_LENLongest LEB128 encoding of a `u64`.
ptwm_core::varint::read_varint
crates/ptwm-core/src/varint.rs:54pub fn read_varint(buf: &[u8], pos: &mut usize) -> Result<u64, VarintError>Read one canonical varint from `buf` at `*pos` and advance `*pos`.
ptwm_core::varint::varint_len
crates/ptwm-core/src/varint.rs:26pub fn varint_len(v: u64) -> usizeNumber of bytes [`write_varint`] uses for `v`.
ptwm_core::varint::VarintError
crates/ptwm-core/src/varint.rs:33pub enum VarintErrorWhy a varint did not parse.
ptwm_core::varint::write_varint
crates/ptwm-core/src/varint.rs:17pub fn write_varint(out: &mut Vec<u8>, v: u64)Append `v` as an unsigned LEB128 varint.