hex_str/
error.rs

1/// An error that may occur when parsing hex strings
2#[allow(clippy::module_name_repetitions)]
3#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
4pub enum HexStringNError {
5    /// The input didn't have required length
6    #[error("invalid input length, expected `{expected}`, encountered: `{encountered}`")]
7    InvalidLength { expected: usize, encountered: usize },
8    /// The input contained invalid character
9    #[error("invalid byte `{a:02x}{b:02x}` encountered at index {index}")]
10    InvalidByte { a: u8, b: u8, index: usize },
11}
12
13/// An error that may occur when parsing hex strings
14#[allow(clippy::module_name_repetitions)]
15#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
16pub enum HexStringError {
17    /// The input didn't have required length
18    #[error("non-even input length, encountered: `{encountered}`")]
19    InvalidLength { encountered: usize },
20    /// The input contained invalid character
21    #[error("invalid byte `{a:02x}{b:02x}` encountered at index {index}")]
22    InvalidByte { a: u8, b: u8, index: usize },
23}