httlib_protos/decoder/
error.rs1use std::error;
2use std::fmt;
3use std::io;
4use std::convert;
5
6#[derive(Debug, PartialEq)]
9pub enum DecoderError {
10 InvalidInput,
13
14 Interrupted,
17
18 InputUnderflow,
21
22 InvalidTag,
26}
27
28impl From<io::Error> for DecoderError {
29 fn from(_err: io::Error) -> Self {
30 Self::Interrupted
31 }
32}
33
34impl From<convert::Infallible> for DecoderError { fn from(_: convert::Infallible) -> Self {
36 unreachable!()
37 }
38}
39
40impl fmt::Display for DecoderError {
41 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
42 match self {
43 Self::InvalidInput => write!(fmt, "Invalid byte stream."),
44 Self::Interrupted => write!(fmt, "Read operation interrupted."),
45 Self::InputUnderflow => write!(fmt, "Not enough bytes."),
46 Self::InvalidTag => write!(fmt, "Found tag with invalid number."),
47 }
48 }
49}
50
51impl error::Error for DecoderError {}