facet_msgpack/
errors.rs

1use core::fmt;
2
3#[derive(Debug)]
4#[non_exhaustive]
5/// Errors that can occur during MessagePack encoding/decoding operations
6pub enum Error {
7    /// Encountered a MessagePack type that doesn't match the expected type
8    UnexpectedType,
9    /// Not enough data available to decode a complete MessagePack value
10    InsufficientData,
11    /// The MessagePack data is malformed or corrupted
12    InvalidData,
13    /// Encountered a field name that isn't recognized
14    UnknownField(String),
15}
16
17impl fmt::Display for Error {
18    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
19        match self {
20            Error::UnexpectedType => write!(f, "Unexpected MessagePack type"),
21            Error::InsufficientData => write!(f, "Insufficient data to decode"),
22            Error::InvalidData => write!(f, "Invalid MessagePack data"),
23            Error::UnknownField(field) => write!(f, "Unknown field: {}", field),
24        }
25    }
26}
27
28impl std::error::Error for Error {}