pub struct ContentHasher { /* private fields */ }Expand description
Constant-space v1 content hashing with an exact, checked payload length.
The length precedes the payload in the immutable v1 framing. Callers must measure and stream the same immutable input. Excess input poisons the hasher; neither incomplete nor poisoned input can produce a digest.
Implementations§
Source§impl ContentHasher
impl ContentHasher
Sourcepub fn new(domain: HashDomain, payload_length: u64) -> Self
pub fn new(domain: HashDomain, payload_length: u64) -> Self
Starts an exact-length, domain-separated SHA-256 v1 frame.
Sourcepub fn update(&mut self, payload: &[u8]) -> Result<(), HashLengthMismatch>
pub fn update(&mut self, payload: &[u8]) -> Result<(), HashLengthMismatch>
Adds bytes without buffering them, refusing and poisoning excess input.
Sourcepub fn finish(self) -> Result<ContentDigest, HashLengthMismatch>
pub fn finish(self) -> Result<ContentDigest, HashLengthMismatch>
Finishes only after exactly the declared number of bytes was supplied.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ContentHasher
impl RefUnwindSafe for ContentHasher
impl Send for ContentHasher
impl Sync for ContentHasher
impl Unpin for ContentHasher
impl UnsafeUnpin for ContentHasher
impl UnwindSafe for ContentHasher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more