use std::fmt::Formatter;
#[derive(Debug, Eq, PartialEq)]
pub struct Error(String);
impl std::error::Error for Error {}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_str(&self.0)
}
}
impl From<String> for Error {
fn from(s: String) -> Self {
Error(s)
}
}
impl From<&str> for Error {
fn from(s: &str) -> Self {
Error(s.to_string())
}
}
impl From<std::string::FromUtf8Error> for Error {
fn from(cause: std::string::FromUtf8Error) -> Self {
Error(format!("{}", cause))
}
}
impl From<serde_json::Error> for Error {
fn from(cause: serde_json::Error) -> Self {
Error(format!("{}", cause))
}
}
impl From<hyper::Error> for Error {
fn from(cause: hyper::Error) -> Self {
Error(format!("{}", cause))
}
}
impl From<hyper::http::Error> for Error {
fn from(cause: hyper::http::Error) -> Self {
Error(format!("{}", cause))
}
}
impl From<hyper::http::uri::InvalidUri> for Error {
fn from(cause: hyper::http::uri::InvalidUri) -> Self {
Error(format!("{}", cause))
}
}
pub type Result<T> = std::result::Result<T, Error>;