pub trait ParallelDigest: Send {
type Digest: Digest;
// Required methods
fn new() -> Self;
fn digest<I: IntoIterator<Item: SerializeBytes>>(
&self,
source: impl IndexedParallelIterator<Item = I>,
out: &mut [MaybeUninit<Output<Self::Digest>>],
);
// Provided method
fn digest_with_const_len<I: IntoIterator<Item: FixedSizeSerializeBytes>>(
&self,
n_items_per_input: usize,
source: impl IndexedParallelIterator<Item = I>,
out: &mut [MaybeUninit<Output<Self::Digest>>],
) { ... }
}Required Associated Types§
Required Methods§
Sourcefn digest<I: IntoIterator<Item: SerializeBytes>>(
&self,
source: impl IndexedParallelIterator<Item = I>,
out: &mut [MaybeUninit<Output<Self::Digest>>],
)
fn digest<I: IntoIterator<Item: SerializeBytes>>( &self, source: impl IndexedParallelIterator<Item = I>, out: &mut [MaybeUninit<Output<Self::Digest>>], )
Calculate the digest of multiple hashes by processing a parallel iterator of iterators.
The source parameter provides a parallel iterator where:
- Each element of the outer iterator maps to one leaf/digest in the output
- Each element contains an inner iterator of items that will be serialized and concatenated to form that leaf’s content
§Panics
All items must be able to serialize with SerializationMode::Native without error, or this method will panic.
Provided Methods§
Sourcefn digest_with_const_len<I: IntoIterator<Item: FixedSizeSerializeBytes>>(
&self,
n_items_per_input: usize,
source: impl IndexedParallelIterator<Item = I>,
out: &mut [MaybeUninit<Output<Self::Digest>>],
)
fn digest_with_const_len<I: IntoIterator<Item: FixedSizeSerializeBytes>>( &self, n_items_per_input: usize, source: impl IndexedParallelIterator<Item = I>, out: &mut [MaybeUninit<Output<Self::Digest>>], )
Like digest, but specialized for the case where every leaf is built from
exactly n_items_per_input items of a [FixedSizeSerializeBytes] type, so that each leaf
has the same, compile-time-derivable byte length.
This extra structure lets implementations skip per-leaf length bookkeeping (and, for short
leaves, the message padding) that digest must redo every time. The default
implementation simply forwards to digest.
§Panics
Each iterator in source must yield exactly n_items_per_input items, and all items must
serialize without error, or this method may panic.
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.