// Copyright 2023 Cryspen Sarl // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0
//! This module provides common interface traits for digest/hashing functionality.
pubmod arrayref; pubmod owned; pubmod slice;
#[cfg(feature = "generic-tests")] pubmod tests;
/// Error indicating that updating the digest state failed. #[derive(Debug, PartialEq)] pubenum UpdateError { /// The length of the provided payload is invalid.
InvalidPayloadLength, ///The maximum input length is exceeded.
MaximumLengthExceeded, /// Unknown error.
Unknown,
}
impl core::fmt::Display for UpdateError { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let text = matchself {
UpdateError::InvalidPayloadLength => "the length of the provided payload is invalid",
UpdateError::MaximumLengthExceeded => "the maximum input length is exceeded",
UpdateError::Unknown => "indicates an unknown error",
};
f.write_str(text)
}
}
#[cfg(feature = "error-in-core")] mod error_in_core {
/// Base trait for incremental functionality. /// /// Traits that are built on top of this trait: /// - [`slice::DigestIncremental`] /// - [`arrayref::DigestIncremental`] /// - [`owned::DigestIncremental`] pubtrait DigestIncrementalBase { /// The digest state. type IncrementalState; /// Reset the digest state. fn reset(state: &mutSelf::IncrementalState); /// Update the digest state with the `payload`. fn update(state: &mutSelf::IncrementalState, payload: &[u8]) -> Result<(), UpdateError>;
}
#[derive(Clone)] /// A hasher that maintains the incremental digest state. pubstruct Hasher<const N: usize, D: DigestIncrementalBase> { /// The digest state. pub state: D::IncrementalState,
}
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.