//! Low-level traits operating on blocks and wrappers around them. //! //! Usage of traits in this module in user code is discouraged. Instead use //! core algorithm wrapped by the wrapper types, which implement the //! higher-level traits. usecrate::InvalidOutputSize;
/// Buffer type used by type which implements [`BufferKindUser`]. pubtype Buffer<S> =
BlockBuffer<<S as BlockSizeUser>::BlockSize, <S as BufferKindUser>::BufferKind>;
/// Types which consume data in blocks. pubtrait UpdateCore: BlockSizeUser { /// Update state using the provided data blocks. fn update_blocks(&mutself, blocks: &[Block<Self>]);
}
/// Types which use [`BlockBuffer`] functionality. pubtrait BufferKindUser: BlockSizeUser { /// Block buffer kind over which type operates. type BufferKind: BufferKind;
}
/// Core trait for hash functions with fixed output size. pubtrait FixedOutputCore: UpdateCore + BufferKindUser + OutputSizeUser where Self::BlockSize: IsLess<U256>,
Le<Self::BlockSize, U256>: NonZero,
{ /// Finalize state using remaining data stored in the provided block buffer, /// write result into provided array and leave `self` in a dirty state. fn finalize_fixed_core(&mutself, buffer: &mut Buffer<Self>, out: &mut Output<Self>);
}
/// Core trait for hash functions with extendable (XOF) output size. pubtrait ExtendableOutputCore: UpdateCore + BufferKindUser where Self::BlockSize: IsLess<U256>,
Le<Self::BlockSize, U256>: NonZero,
{ /// XOF reader core state. type ReaderCore: XofReaderCore;
/// Retrieve XOF reader using remaining data stored in the block buffer /// and leave hasher in a dirty state. fn finalize_xof_core(&mutself, buffer: &>mut Buffer<Self>) -> Self::ReaderCore;
}
/// Core reader trait for extendable-output function (XOF) result. pubtrait XofReaderCore: BlockSizeUser { /// Read next XOF block. fn read_block(&mutself) -> Block<Self>;
}
/// Core trait for hash functions with variable output size. /// /// Maximum output size is equal to [`OutputSizeUser::OutputSize`]. /// Users are expected to truncate result returned by the /// [`finalize_variable_core`] to `output_size` passed to the [`new`] method /// during construction. Truncation side is defined by the [`TRUNC_SIDE`] /// associated constant. /// /// [`finalize_variable_core`]: VariableOutputCore::finalize_variable_core /// [`new`]: VariableOutputCore::new /// [`TRUNC_SIDE`]: VariableOutputCore::TRUNC_SIDE pubtrait VariableOutputCore: UpdateCore + OutputSizeUser + BufferKindUser + Sized where Self::BlockSize: IsLess<U256>,
Le<Self::BlockSize, U256>: NonZero,
{ /// Side which should be used in a truncated result. const TRUNC_SIDE: TruncSide;
/// Initialize hasher state for given output size. /// /// Returns [`InvalidOutputSize`] if `output_size` is not valid for /// the algorithm, e.g. if it's bigger than the [`OutputSize`] /// associated type. /// /// [`OutputSize`]: OutputSizeUser::OutputSize fn new(output_size: usize) -> Result<Self, InvalidOutputSize>;
/// Finalize hasher and write full hashing result into the `out` buffer. /// /// The result must be truncated to `output_size` used during hasher /// construction. Truncation side is defined by the [`TRUNC_SIDE`] /// associated constant. /// /// [`TRUNC_SIDE`]: VariableOutputCore::TRUNC_SIDE fn finalize_variable_core(&mutself, buffer: &mut Buffer<Self>, out: &mut Output<Self>);
}
/// Type which used for defining truncation side in the [`VariableOutputCore`] /// trait. #[derive(Copy, Clone, Debug)] pubenum TruncSide { /// Truncate left side, i.e. `&out[..n]`.
Left, /// Truncate right side, i.e. `&out[m..]`.
Right,
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet am 2026-06-18)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.