rust-wechat-core 0.1.3

wechat api core
Documentation
use std::fmt::Display;
use std::io;
use serde::Deserialize;
use crate::__setter;

#[derive(Debug, Default, thiserror::Error, Deserialize)]
pub struct ServerError {
    pub code: i32,
    pub message: Option<String>,
}
impl ServerError {
    __setter!(code: i32);
    __setter!(message: Option<String>);
}

impl Display for ServerError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "code: {}, message: {}", self.code, &self.message.clone().unwrap_or("".to_string()))
    }
}

#[derive(Debug, thiserror::Error)]
pub enum WechatError {
    #[error(transparent)]
    ServerError(ServerError),
    #[error("reqwest error: {0}")]
    RequestError(#[from] reqwest::Error),
    #[error("common error: {0}")]
    CommonError(String),
    #[error("common error: {0}")]
    IoError(#[from] io::Error),
    #[error("unsupported command: {0}")]
    UnsupportedCommand(String),
}