1use core::fmt;
2
3#[derive(Debug)]
4#[non_exhaustive]
5pub enum Error {
7 UnexpectedType,
9 InsufficientData,
11 InvalidData,
13 UnknownField(String),
15 MissingField(String),
17 IntegerOverflow,
19 UnsupportedShape(String),
21 UnsupportedType(String),
23}
24
25impl fmt::Display for Error {
26 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27 match self {
28 Error::UnexpectedType => write!(f, "Unexpected MessagePack type"),
29 Error::InsufficientData => write!(f, "Insufficient data to decode"),
30 Error::InvalidData => write!(f, "Invalid MessagePack data"),
31 Error::UnknownField(field) => write!(f, "Unknown field: {}", field),
32 Error::MissingField(field) => write!(f, "Missing required field: {}", field),
33 Error::IntegerOverflow => write!(f, "Integer value too large for target type"),
34 Error::UnsupportedShape(shape) => {
35 write!(f, "Unsupported shape for deserialization: {}", shape)
36 }
37 Error::UnsupportedType(typ) => {
38 write!(f, "Unsupported type for deserialization: {}", typ)
39 }
40 }
41 }
42}
43
44impl std::error::Error for Error {}