use pest; use serde::de; use std::fmt::{self, Display}; use crate::Rule; pub type MpdResult = std::result::Result; #[derive(Clone, Debug, PartialEq)] pub struct Error { pub message: String, } impl From> for Error { fn from(err: pest::error::Error) -> Self { Error { message: err.to_string(), } } } impl de::Error for Error { fn custom(msg: T) -> Self { Error { message: msg.to_string(), } } } impl Display for Error { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { formatter.write_str(&self.message) } } impl std::error::Error for Error { fn description(&self) -> &str { &self.message } }