screenshotfreeapi 1.0.0

Official Rust client for ScreenshotFreeAPI — Screenshot-as-a-Service
Documentation
/// All errors that can be returned by the ScreenshotFreeAPI client.
#[derive(Debug, thiserror::Error)]
pub enum ScreenshotFreeAPIError {
    /// An underlying HTTP transport error from `reqwest`.
    #[error("HTTP error: {0}")]
    Http(#[from] reqwest::Error),

    /// The API key or JWT was missing, invalid, or has been revoked (HTTP 401).
    #[error("Authentication failed: {message}")]
    Authentication { message: String },

    /// The caller does not have permission to access this resource (HTTP 403).
    #[error("Forbidden: {message}")]
    Forbidden { message: String },

    /// The requested resource was not found or does not belong to this API key (HTTP 404).
    #[error("Not found: {message}")]
    NotFound { message: String },

    /// The request body failed validation (HTTP 400).
    #[error("Validation error: {message}")]
    Validation { message: String },

    /// The rate limit was hit. The client should wait `retry_after_seconds` before retrying (HTTP 429).
    #[error("Rate limited, retry after {retry_after_seconds}s")]
    RateLimit { retry_after_seconds: u64 },

    /// The monthly screenshot quota for this plan has been exhausted (HTTP 429 with quota body).
    #[error("Quota exceeded")]
    QuotaExceeded,

    /// Payment is required — subscription cancelled or payment overdue (HTTP 402).
    #[error("Payment required: {message}")]
    PaymentRequired { message: String },

    /// The screenshot job completed with a failure state.
    #[error("Job failed: {reason}")]
    JobFailed { job_id: String, reason: String },

    /// The caller's polling loop exceeded `timeout_ms` without the job completing.
    #[error("Job timed out after {timeout_ms}ms")]
    JobTimeout { timeout_ms: u64 },

    /// The `X-ScreenshotFree-Signature` header did not match the computed HMAC-SHA256 of the body.
    #[error("Invalid webhook signature")]
    InvalidSignature,

    /// An unexpected HTTP status code was returned that does not map to any typed variant.
    #[error("Unexpected status {status}: {message}")]
    Unexpected { status: u16, message: String },
}

/// Convenience alias used throughout this crate.
pub type Result<T> = std::result::Result<T, ScreenshotFreeAPIError>;