pub trait PayloadDigest:
Ord
+ Default
+ Clone
+ Debug {
type Hasher;
// Required methods
fn hasher() -> Self::Hasher;
fn finish(hasher: &Self::Hasher) -> Self;
fn write(hasher: &mut Self::Hasher, bytes: &[u8]);
}Expand description
A totally ordered type for content-addressing the data that Willow stores.
This trait mirrors the std::hash::Hasher trait (with the hasher state as an associated type), but hashing not to u64s but to Selfs.
§Implementation notes
The Default implementation must return the least element in the total order of PayloadDigest.
Required Associated Types§
Required Methods§
Sourcefn hasher() -> Self::Hasher
fn hasher() -> Self::Hasher
Returns the initial state for hashing, i.e., the hash for the empty string.
Sourcefn finish(hasher: &Self::Hasher) -> Self
fn finish(hasher: &Self::Hasher) -> Self
Returns the digest for the values written so far.
Despite its name, the method does not reset the hasher’s internal state. Additional writes will continue from the current value. If you need to start a fresh hash value, you will have to create a new hasher.
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.