base16384/
error.rs

1//! Error types.
2
3use core::fmt::Display;
4#[cfg(feature = "std")]
5use std::error::Error;
6
7/// Errors that can occur when decoding base16384.
8#[derive(Debug, PartialEq)]
9pub enum Base16384DecodeError {
10    /// The input data has an invalid length.
11    InvalidLength,
12    /// The input data has an invalid character at the given index.
13    InvalidCharacter {
14        /// The index of the invalid character.
15        ///
16        /// In UTF-8, this is the byte index.
17        index: usize,
18    },
19}
20
21impl Display for Base16384DecodeError {
22    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
23        match self {
24            Self::InvalidLength => write!(f, "invalid length"),
25            Self::InvalidCharacter { index } => write!(f, "invalid character at index {}", index),
26        }
27    }
28}
29
30#[cfg(feature = "std")]
31impl Error for Base16384DecodeError {}