HashFunction

Trait HashFunction 

Source
pub trait HashFunction<const DIGEST_LENGTH: usize>: Default {
    const OUTPUT_SIZE: usize = DIGEST_LENGTH;

    // Required methods
    fn update<Data: AsRef<[u8]>>(&mut self, data: Data);
    fn finalize(self) -> Digest<DIGEST_LENGTH>;

    // Provided methods
    fn new() -> Self { ... }
    fn digest<Data: AsRef<[u8]>>(data: Data) -> Digest<DIGEST_LENGTH> { ... }
    fn digest_iterator<K: AsRef<[u8]>, I: Iterator<Item = K>>(
        iter: I,
    ) -> Digest<DIGEST_LENGTH> { ... }
}
Expand description

Trait implemented by hash functions providing a output of fixed length

Provided Associated Constants§

Source

const OUTPUT_SIZE: usize = DIGEST_LENGTH

The length of this hash functions digests in bytes.

Required Methods§

Source

fn update<Data: AsRef<[u8]>>(&mut self, data: Data)

Process the given data, and update the internal of the hash function.

Source

fn finalize(self) -> Digest<DIGEST_LENGTH>

Retrieve result and consume hash function.

Provided Methods§

Source

fn new() -> Self

Create a new hash function of the given type

Source

fn digest<Data: AsRef<[u8]>>(data: Data) -> Digest<DIGEST_LENGTH>

Compute the digest of the given data and consume the hash function.

Source

fn digest_iterator<K: AsRef<[u8]>, I: Iterator<Item = K>>( iter: I, ) -> Digest<DIGEST_LENGTH>

Compute a single digest from all slices in the iterator in order and consume the hash function.

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<Variant: Digest + Default, const DIGEST_LEN: usize> HashFunction<DIGEST_LEN> for HashFunctionWrapper<Variant, DIGEST_LEN>