2020-01-05 22:15:43 +00:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum Error {
|
|
|
|
HeaderSizeTooSmall,
|
2020-04-11 13:39:43 +00:00
|
|
|
InvalidBodyType(u8),
|
2020-01-05 22:15:43 +00:00
|
|
|
Io(async_std::io::Error),
|
|
|
|
Json(serde_json::Error),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<async_std::io::Error> for Error {
|
|
|
|
fn from(err: async_std::io::Error) -> Self {
|
|
|
|
Error::Io(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<serde_json::Error> for Error {
|
|
|
|
fn from(err: serde_json::Error) -> Self {
|
|
|
|
Error::Json(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::fmt::Display for Error {
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
|
|
write!(f, "{:?}", self)
|
|
|
|
}
|
|
|
|
}
|
2020-02-14 15:39:31 +00:00
|
|
|
impl std::error::Error for Error {}
|
2020-01-05 22:15:43 +00:00
|
|
|
|
|
|
|
pub type Result<T> = std::result::Result<T, Error>;
|