weixin-agent 0.3.0

Pure protocol SDK for Weixin iLink Bot API — iLink AI Bot protocol, not coupled with OpenClaw
Documentation
//! Unified error types for the weixin-agent SDK.

/// All errors produced by this SDK.
#[derive(thiserror::Error, Debug)]
#[non_exhaustive]
pub enum Error {
    /// HTTP transport error.
    #[error("HTTP request failed: {0}")]
    Http(#[from] reqwest::Error),

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

    /// File I/O error.
    #[error("I/O error: {0}")]
    Io(#[from] std::io::Error),

    /// Server returned a non-zero error code.
    #[error("API error: errcode={errcode}, errmsg={errmsg}")]
    Api {
        /// Server error code.
        errcode: i32,
        /// Server error message.
        errmsg: String,
    },

    /// Bot token is stale; the poll loop has entered its cooldown window.
    ///
    /// Only long polling is paused — outbound calls are not blocked by the SDK.
    #[error("bot token is stale (errcode -14), polling paused for cooldown")]
    TokenStale,

    /// Deprecated: use [`Error::TokenStale`].
    #[deprecated(since = "0.3.0", note = "use Error::TokenStale")]
    #[error("session expired for account, paused until cooldown")]
    SessionExpired,

    /// CDN upload failure.
    #[error("CDN upload failed: {0}")]
    CdnUpload(String),

    /// AES encryption/decryption failure.
    #[error("Encryption error: {0}")]
    Crypto(String),

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

    /// Operation timed out.
    #[error("Timeout: {0}")]
    Timeout(String),
}

/// Convenience alias used throughout the SDK.
pub type Result<T> = std::result::Result<T, Error>;