Trait PayloadDigest

Source
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.

Definition.

§Implementation notes

The Default implementation must return the least element in the total order of PayloadDigest.

Required Associated Types§

Source

type Hasher

The state for hashing slices of bytes.

Required Methods§

Source

fn hasher() -> Self::Hasher

Returns the initial state for hashing, i.e., the hash for the empty string.

Source

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.

Source

fn write(hasher: &mut Self::Hasher, bytes: &[u8])

Writes some data into the given 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.

Implementors§