Skip to main content

hsh_digest/
error.rs

1// Copyright © 2023-2026 Hash (HSH) library contributors. All rights reserved.
2// SPDX-License-Identifier: Apache-2.0 OR MIT
3
4//! Structured error type for the `hsh-digest` crate.
5
6use thiserror::Error;
7
8/// Errors returned by [`crate::Hasher`] and [`crate::hash`].
9#[derive(Debug, Error)]
10#[non_exhaustive]
11pub enum DigestError {
12    /// The requested algorithm wasn't compiled into this build (its
13    /// Cargo feature was disabled).
14    ///
15    /// Today this is unreachable because the [`crate::Algorithm`]
16    /// variants are themselves feature-gated. Kept for forward
17    /// compatibility with the planned runtime-selectable algorithm
18    /// table.
19    #[error("algorithm {0:?} is not available in this build")]
20    Unavailable(&'static str),
21}