use core::fmt::{Debug, Display, Formatter};
pub type Result<T> = core::result::Result<T, Error<T>>;
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub enum Error<T> {
StreamNotExhausted {
instance: T,
next_byte: u8,
},
UnexpectedEndOfStream,
}
impl<T> Display for Error<T> {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
match self {
Self::StreamNotExhausted { next_byte, .. } => {
write!(f, "byte stream not exhausted: [{next_byte:#04X?}, ..]")
}
Self::UnexpectedEndOfStream => write!(f, "unexpected end of stream"),
}
}
}
impl<T> core::error::Error for Error<T> where T: Debug {}