Skip to main content

Hasher

Trait Hasher 

Source
pub trait Hasher: Send {
    // Required methods
    fn update(&mut self, data: &[u8]);
    fn finalize(self: Box<Self>) -> Vec<u8> ;
    fn algorithm(&self) -> HashAlgorithm;
}
Expand description

Incremental hashing.

Modeled after the digest crate’s DynDigest so providers can trivially adapt — but stripped to just the operations PDF needs (no XOF, no variable-output, no reset).

Required Methods§

Source

fn update(&mut self, data: &[u8])

Feed input into the hash state. May be called any number of times before Self::finalize.

Source

fn finalize(self: Box<Self>) -> Vec<u8>

Finalize the hash, consuming self. The returned Vec is exactly HashAlgorithm::output_size bytes long.

Boxed receiver lets implementors live behind Box<dyn Hasher> without paying for Sized constraints up the call stack.

Source

fn algorithm(&self) -> HashAlgorithm

Reports the algorithm so callers can sanity-check the output size or feed the right OID into a CMS construction.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§