use std::fmt::{Display, Formatter};
#[derive(Debug, Clone)]
pub struct Error {
message: String,
}
pub type Result<T> = std::result::Result<T, Error>;
impl serde::de::Error for Error {
fn custom<T>(msg: T) -> Self
where
T: Display,
{
Self {
message: msg.to_string(),
}
}
}
impl serde::ser::Error for Error {
fn custom<T>(msg: T) -> Self
where
T: Display,
{
Self {
message: msg.to_string(),
}
}
}
impl std::error::Error for Error {}
impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_str(self.message.as_str())
}
}