jmt

Trait SimpleHasher

Source
pub trait SimpleHasher: Sized {
    // Required methods
    fn new() -> Self;
    fn update(&mut self, data: &[u8]);
    fn finalize(self) -> [u8; 32];

    // Provided method
    fn hash(data: impl AsRef<[u8]>) -> [u8; 32] { ... }
}
Expand description

A minimal trait representing a hash function. We implement our own rather than relying on Digest for broader compatibility.

Required Methods§

Source

fn new() -> Self

Creates a new hasher with default state.

Source

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

Ingests the provided data, updating the hasher’s state.

Source

fn finalize(self) -> [u8; 32]

Consumes the hasher state to produce a digest.

Provided Methods§

Source

fn hash(data: impl AsRef<[u8]>) -> [u8; 32]

Returns the digest of the provided data.

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§

Source§

impl SimpleHasher for TransparentHasher

Source§

impl<T: Digest> SimpleHasher for T
where [u8; 32]: From<GenericArray<u8, <T as OutputSizeUser>::OutputSize>>,