pub trait Hasher<H: CHasher>: Send + Sync {
// Required methods
fn leaf_digest(&mut self, pos: u64, element: &[u8]) -> H::Digest;
fn node_digest(
&mut self,
pos: u64,
left: &H::Digest,
right: &H::Digest,
) -> H::Digest;
fn root<'a>(
&mut self,
size: u64,
peak_digests: impl Iterator<Item = &'a H::Digest>,
) -> H::Digest;
fn digest(&mut self, data: &[u8]) -> H::Digest;
fn inner(&mut self) -> &mut H;
fn fork(&self) -> impl Hasher<H>;
}
Expand description
A trait for computing the various digests of an MMR.
Required Methods§
Sourcefn leaf_digest(&mut self, pos: u64, element: &[u8]) -> H::Digest
fn leaf_digest(&mut self, pos: u64, element: &[u8]) -> H::Digest
Computes the digest for a leaf given its position and the element it represents.
Sourcefn node_digest(
&mut self,
pos: u64,
left: &H::Digest,
right: &H::Digest,
) -> H::Digest
fn node_digest( &mut self, pos: u64, left: &H::Digest, right: &H::Digest, ) -> H::Digest
Computes the digest for a node given its position and the digests of its children.
Sourcefn root<'a>(
&mut self,
size: u64,
peak_digests: impl Iterator<Item = &'a H::Digest>,
) -> H::Digest
fn root<'a>( &mut self, size: u64, peak_digests: impl Iterator<Item = &'a H::Digest>, ) -> H::Digest
Computes the root for an MMR given its size and an iterator over the digests of its peaks in decreasing order of height.
Sourcefn fork(&self) -> impl Hasher<H>
fn fork(&self) -> impl Hasher<H>
Fork the hasher to provide equivalent functionality in another thread. This is different than Clone::clone because the forked hasher need not be a deep copy, and may share non-mutable state with the hasher from which it was forked.
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.