Hasher

Trait Hasher 

Source
pub trait Hasher {
    type Output;

    // Required methods
    fn update(&mut self, input: impl AsRef<[u8]>);
    fn finalize(self) -> Self::Output;
}
Expand description

A trait for hashing an arbitrary stream of bytes.

Instances of Hasher usually represent state that is changed while hashing data.

Hasher provides a fairly basic interface for retrieving the generated hash (with Hasher::finalize), and absorbing an arbitrary number of bytes (with Hasher::update). Most of the time, Hasher instances are used in conjunction with the Hash trait.

Required Associated Types§

Source

type Output

The output type of this hasher.

For core::hash types, it’s u64. For tiny_keccak, it’s [u8]. For this crate, it’s [u8; 32].

Required Methods§

Source

fn update(&mut self, input: impl AsRef<[u8]>)

Absorb additional input. Can be called multiple times.

Source

fn finalize(self) -> Self::Output

Output the hashing algorithm state.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§