pub struct ContentHasher { /* private fields */ }Expand description
Incremental content hasher producing a stable lowercase-hex digest.
Backed by BLAKE3. Feed bytes with update (raw) or
update_framed (domain-separated), then read the
digest with finalize_hex. The hasher may be reused
after finalizing; finalizing does not consume it.
Implementations§
Source§impl ContentHasher
impl ContentHasher
Sourcepub fn update(&mut self, bytes: &[u8]) -> &mut Self
pub fn update(&mut self, bytes: &[u8]) -> &mut Self
Fold bytes into the digest verbatim, without framing.
Returns &mut Self so updates can be chained.
Sourcepub fn update_framed(&mut self, label: &[u8], value: &[u8]) -> &mut Self
pub fn update_framed(&mut self, label: &[u8], value: &[u8]) -> &mut Self
Fold a labelled value into the digest with unambiguous framing.
Each of label and value is folded length-prefixed (its length as a
little-endian u64, then its bytes), so field boundaries stay
unambiguous even when the inputs contain arbitrary bytes such as : or
\0. Independently folded fields therefore cannot alias one another.
Returns &mut Self so updates can be chained.
Sourcepub fn finalize_hex(&self) -> String
pub fn finalize_hex(&self) -> String
Render the current digest as a lowercase hexadecimal string.
Does not consume the hasher: further updates may follow and produce a new digest.
Trait Implementations§
Source§impl Clone for ContentHasher
impl Clone for ContentHasher
Source§fn clone(&self) -> ContentHasher
fn clone(&self) -> ContentHasher
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more