1use core::fmt::{Debug, Display, Formatter};
2
3pub type Result<T> = core::result::Result<T, Error<T>>;
5
6#[derive(Clone, Debug, Eq, Hash, PartialEq)]
8pub enum Error<T> {
9 StreamNotExhausted {
11 instance: T,
13 next_byte: u8,
15 },
16 UnexpectedEndOfStream,
18}
19
20impl<T> Display for Error<T> {
21 fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
22 match self {
23 Self::StreamNotExhausted { next_byte, .. } => {
24 write!(f, "byte stream not exhausted: [{next_byte:#04X?}, ..]")
25 }
26 Self::UnexpectedEndOfStream => write!(f, "unexpected end of stream"),
27 }
28 }
29}
30
31impl<T> core::error::Error for Error<T> where T: Debug {}