garage-sdk 0.1.1

Async Rust SDK for Garage S3-compatible storage with uploads and public URL generation
Documentation
use thiserror::Error;

/// All possible errors that can occur when using the Garage SDK.
#[derive(Error, Debug)]
pub enum Error {
    /// Configuration is invalid or incomplete.
    #[error("Configuration error: {message}")]
    Config { message: String },

    /// Failed to parse or validate a URL.
    #[error("Invalid URL '{url}': {reason}")]
    InvalidUrl { url: String, reason: String },

    /// Failed to read a local file.
    #[error("Failed to read file '{path}': {source}")]
    FileRead {
        path: String,
        #[source]
        source: std::io::Error,
    },

    /// Failed to download content from a URL.
    #[error("Failed to download from '{url}': {reason}")]
    Download { url: String, reason: String },

    /// HTTP request failed.
    #[error("HTTP error: {0}")]
    Http(#[from] reqwest::Error),

    /// S3 operation failed.
    #[error("S3 operation failed: {operation} - {reason}")]
    S3Operation { operation: String, reason: String },

    /// Content type could not be determined.
    #[error("Could not determine content type for '{filename}'")]
    UnknownContentType { filename: String },

    /// Invalid file path provided.
    #[error("Invalid file path: {reason}")]
    InvalidPath { reason: String },
}

/// Result type alias for Garage SDK operations.
pub type Result<T> = std::result::Result<T, Error>;