secure_gate/
error.rs

1//! Centralized error types for the secure-gate crate.
2
3#[cfg(feature = "encoding-bech32")]
4/// Error type for Bech32 encoding operations.
5#[derive(Clone, Copy, Debug, PartialEq, Eq, thiserror::Error)]
6pub enum Bech32EncodingError {
7    #[error("invalid Human-Readable Part (HRP)")]
8    InvalidHrp,
9    #[error("encoding operation failed")]
10    EncodingFailed,
11}
12
13/// Error for slice length mismatches in TryFrom impls.
14#[derive(Debug, thiserror::Error)]
15#[error("slice length mismatch: expected {expected_len} bytes, got {actual_len} bytes")]
16pub struct FromSliceError {
17    pub(crate) actual_len: usize,
18    pub(crate) expected_len: usize,
19}
20
21impl FromSliceError {
22    /// Create a new FromSliceError with the actual and expected lengths.
23    pub(crate) fn new(actual_len: usize, expected_len: usize) -> Self {
24        Self {
25            actual_len,
26            expected_len,
27        }
28    }
29}