planck_pack_core/
error.rs1use core::fmt;
2
3#[derive(Debug, Clone, PartialEq, Eq)]
5pub enum DecodeError {
6 OrdinalOutOfRange { ordinal: u128, radix: u128 },
8 ExcessData,
10 InsufficientData { expected: usize, got: usize },
12}
13
14impl fmt::Display for DecodeError {
15 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
16 match self {
17 DecodeError::OrdinalOutOfRange { ordinal, radix } => {
18 write!(f, "ordinal {ordinal} out of range for radix {radix}")
19 }
20 DecodeError::ExcessData => {
21 write!(f, "excess data after decoding all fields")
22 }
23 DecodeError::InsufficientData { expected, got } => {
24 write!(f, "insufficient data: expected {expected} bytes, got {got}")
25 }
26 }
27 }
28}
29
30#[cfg(feature = "std")]
31impl std::error::Error for DecodeError {}