#[derive(Debug, PartialEq)]
pub enum HashError {
InvalidPayloadLength,
Unknown,
}
impl core::fmt::Display for HashError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let text = match self {
HashError::InvalidPayloadLength => "the length of the provided payload is invalid",
HashError::Unknown => "indicates an unknown error",
};
f.write_str(text)
}
}
#[cfg(feature = "error-in-core")]
mod error_in_core {
impl core::error::Error for super::HashError {}
}
pub trait DigestIncremental<const OUTPUT_LEN: usize>: super::DigestIncrementalBase {
fn finish(state: &mut Self::IncrementalState, digest: &mut [u8; OUTPUT_LEN]);
}
pub trait Hash<const OUTPUT_LEN: usize> {
fn hash(digest: &mut [u8; OUTPUT_LEN], payload: &[u8]) -> Result<(), HashError>;
}