use serde::de; use std::fmt::{self, Display}; pub type MpdResult = std::result::Result; #[derive(Clone, Debug, PartialEq)] pub struct Error { pub message: String, } impl Error { pub fn from_str(message: &str) -> Self { Error { message: message.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 } }