pub struct StateHasher { /* private fields */ }Expand description
An explicit BLAKE3 writer for deterministic state.
The encoding is schema-driven: each write appends its fixed-width
little-endian bytes without a type tag, and bytes and
sequence prefix a u32 length. The schema is the shape
of the primitive writes: which methods, in what order. Write sequences with
the same schema hash differently whenever their values differ, provided
each CanonicalWrite it uses is self-delimiting. Different schemas may encode alike —
u16(0x1234) equals u8(0x34); u8(0x12) — so a caller that hashes several
kinds of state in one stream, or changes what it writes, separates them
itself with a leading tag or version (for example u32(KIND)).
Implementations§
Source§impl StateHasher
impl StateHasher
Sourcepub fn length(&mut self, length: usize)
pub fn length(&mut self, length: usize)
Appends a collection length as u32.
§Panics
Panics when length cannot be represented in the frozen format.
Sourcepub fn write<T: CanonicalWrite + ?Sized>(&mut self, value: &T)
pub fn write<T: CanonicalWrite + ?Sized>(&mut self, value: &T)
Appends a canonical value.
Sourcepub fn sequence<T: CanonicalWrite>(&mut self, values: &[T])
pub fn sequence<T: CanonicalWrite>(&mut self, values: &[T])
Appends an ordered sequence with a u32 length prefix.