use std::fmt;
pub type Result<T, E = Error> = std::result::Result<T, E>;
#[derive(Debug)]
pub enum Error {
Host(String),
Codec(String),
Denied(String),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::Host(m) => write!(f, "host error: {m}"),
Error::Codec(m) => write!(f, "codec error: {m}"),
Error::Denied(m) => write!(f, "denied: {m}"),
}
}
}
impl std::error::Error for Error {}
impl From<serde_json::Error> for Error {
fn from(err: serde_json::Error) -> Self {
Error::Codec(err.to_string())
}
}