pub trait MultiDigest<const N: usize>: Clone {
type Digest: Digest;
// Required methods
fn new() -> Self;
fn update(&mut self, data: [&[u8]; N]);
fn finalize_into(self, out: &mut [MaybeUninit<Output<Self::Digest>>; N]);
fn finalize_into_reset(
&mut self,
out: &mut [MaybeUninit<Output<Self::Digest>>; N],
);
fn reset(&mut self);
fn digest(
data: [&[u8]; N],
out: &mut [MaybeUninit<Output<Self::Digest>>; N],
);
// Provided methods
fn new_with_prefix(data: impl AsRef<[u8]>) -> Self { ... }
fn chain_update(self, data: [&[u8]; N]) -> Self { ... }
}
Expand description
An object that efficiently computes N
instances of a cryptographic hash function
in parallel.
This trait is useful when there is a more efficient way of calculating multiple digests at once,
e.g. using SIMD instructions. It is supposed that this trait is implemented directly for some digest and
some fixed N
and passed as an implementation of the ParallelDigest
trait which hides the N
value.
Required Associated Types§
Required Methods§
Sourcefn update(&mut self, data: [&[u8]; N])
fn update(&mut self, data: [&[u8]; N])
Process data, updating the internal state.
The number of rows in data
must be equal to parallel_instances()
.
Sourcefn finalize_into(self, out: &mut [MaybeUninit<Output<Self::Digest>>; N])
fn finalize_into(self, out: &mut [MaybeUninit<Output<Self::Digest>>; N])
Write result into provided array and consume the hasher instance.
Sourcefn finalize_into_reset(
&mut self,
out: &mut [MaybeUninit<Output<Self::Digest>>; N],
)
fn finalize_into_reset( &mut self, out: &mut [MaybeUninit<Output<Self::Digest>>; N], )
Write result into provided array and reset the hasher instance.
Provided Methods§
Sourcefn new_with_prefix(data: impl AsRef<[u8]>) -> Self
fn new_with_prefix(data: impl AsRef<[u8]>) -> Self
Create new hasher instance which has processed the provided data.
Sourcefn chain_update(self, data: [&[u8]; N]) -> Self
fn chain_update(self, data: [&[u8]; N]) -> Self
Process input data in a chained manner.
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.