use core::fmt::{self, Display, Debug};
pub type Result<T> = core::result::Result<T, Error>;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Error {
BufferTooSmall,
UnexpectedEof,
InvalidData,
TypeMismatch,
OutOfRange,
Custom(&'static str),
Unsupported,
}
impl Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::BufferTooSmall => write!(f, "Buffer too small"),
Error::UnexpectedEof => write!(f, "Unexpected end of data"),
Error::InvalidData => write!(f, "Invalid data format"),
Error::TypeMismatch => write!(f, "Type mismatch"),
Error::OutOfRange => write!(f, "Value out of range"),
Error::Custom(msg) => write!(f, "Custom error: {}", msg),
Error::Unsupported => write!(f, "Unsupported operation"),
}
}
}
#[cfg(feature = "std")]
impl std::error::Error for Error {}