wechat-api-rs 0.1.0

A Rust SDK for WeChat Official Account and Mini Program APIs
Documentation
use thiserror::Error;

/// WeChat SDK error types
#[derive(Error, Debug)]
pub enum WeChatError {
    #[error("HTTP request failed: {0}")]
    Http(String),

    #[error("Reqwest error: {0}")]
    Reqwest(#[from] reqwest::Error),

    #[error("JSON serialization/deserialization failed: {0}")]
    Json(#[from] serde_json::Error),

    #[error("WeChat API error: {code} - {message}")]
    Api { code: i32, message: String },

    #[error("Invalid configuration: {0}")]
    Config(String),

    #[error("Authentication failed: {0}")]
    Auth(String),

    #[error("Signature verification failed")]
    Signature,

    #[error("Encryption/Decryption failed: {0}")]
    Crypto(String),

    #[error("Invalid parameter: {0}")]
    InvalidParam(String),

    #[error("Other error: {0}")]
    Other(String),
}

/// Result type alias for WeChat SDK
pub type Result<T> = std::result::Result<T, WeChatError>;