precolator-sdk 1.0.0

Rust async client SDK for the Precolator perpetual futures trading platform — markets, portfolio, leaderboard, and trading statistics.
Documentation
use thiserror::Error;

/// Unified error type for the Precolator SDK.
#[derive(Debug, Error)]
pub enum PrecolatorError {
    /// HTTP transport or TLS error from reqwest.
    #[error("HTTP error: {0}")]
    Http(#[from] reqwest::Error),

    /// The API returned a non-success status code.
    #[error("API error {status}: {message}")]
    Api { status: u16, message: String },

    /// A URL could not be parsed.
    #[error("Invalid URL: {0}")]
    InvalidUrl(#[from] url::ParseError),

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

    /// The requested resource was not found.
    #[error("Resource not found: {0}")]
    NotFound(String),

    /// Rate limit exceeded.
    #[error("Rate limit exceeded — retry after {retry_after_secs}s")]
    RateLimited { retry_after_secs: u64 },
}

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