mparsed 0.2.0

Structs and logic to deserialize mpd (music player daemon) responses with serde
Documentation
use serde::de;
use std::fmt::{self, Display};

pub type MpdResult<T> = std::result::Result<T, Error>;

#[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<T: Display>(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
  }
}