pub trait HashFunction: ReprC {
type Output: AsRef<[u8]> + ReprC;
// Required methods
fn update(&mut self, data: impl AsRef<[u8]>);
fn write_result(&self, output: &mut Self::Output);
// Provided method
fn result(&self) -> Self::Output { ... }
}Expand description
Represents a general hash function. Unlike core::hash::Hasher
trait it doesn’t mandate output type, except that it needs to
be [AsRef<[u8]>]. This makes it suitable for implementing larger
hash function like SHA.
Required Associated Types§
Required Methods§
Sourcefn update(&mut self, data: impl AsRef<[u8]>)
fn update(&mut self, data: impl AsRef<[u8]>)
Updates the internal state of the HashFunction with given data.
Sourcefn write_result(&self, output: &mut Self::Output)
fn write_result(&self, output: &mut Self::Output)
Writes the final result to the output passed as ref parameter.
Provided Methods§
Sourcefn result(&self) -> Self::Output
fn result(&self) -> Self::Output
A wrapper around HashFunction::write_result that returns the hash
instead of writing it to output parameter.
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.