use std::{fmt::Display, io};
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug)]
pub enum Error {
Io(io::Error),
#[cfg(feature = "http")]
Http(reqwest::Error),
Serde(serde_json::Error),
}
impl Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Io(error) => write!(f, "{}", error),
#[cfg(feature = "http")]
Self::Http(error) => write!(f, "{}", error),
Self::Serde(error) => write!(f, "{}", error),
}
}
}
impl From<io::Error> for Error {
fn from(err: io::Error) -> Self {
Self::Io(err)
}
}
#[cfg(feature = "http")]
impl From<reqwest::Error> for Error {
fn from(err: reqwest::Error) -> Self {
Self::Http(err)
}
}
impl From<serde_json::Error> for Error {
fn from(err: serde_json::Error) -> Self {
Self::Serde(err)
}
}