crypsol_storage 0.2.0

Multi-cloud storage library for Rust with image processing, validation, and thumbnail generation. Supports AWS S3, GCS, Azure Blob, Cloudflare R2, MinIO, and local filesystem.
Documentation
use std::future::Future;

use bytes::Bytes;

use crate::error::Error;
use crate::types::{PutOptions, RawDownloadResult};

/// Trait for storage backends.
///
/// Implementations provide the low-level storage operations;
/// [`StorageService`](crate::StorageService) adds image processing,
/// validation, and higher-level orchestration on top.
pub trait StorageBackend: Send + Sync {
    /// Upload an object.
    fn put_object(
        &self,
        key: &str,
        data: Bytes,
        content_type: &str,
        options: &PutOptions,
    ) -> impl Future<Output = Result<(), Error>> + Send;

    /// Download an object.
    fn get_object(
        &self,
        key: &str,
    ) -> impl Future<Output = Result<RawDownloadResult, Error>> + Send;

    /// Delete an object.
    fn delete_object(&self, key: &str) -> impl Future<Output = Result<(), Error>> + Send;

    /// Check whether an object exists.
    fn exists(&self, key: &str) -> impl Future<Output = Result<bool, Error>> + Send;

    /// Generate a presigned GET URL.
    fn presigned_get_url(
        &self,
        key: &str,
        expires_in_secs: u64,
    ) -> impl Future<Output = Result<String, Error>> + Send;

    /// Generate a presigned PUT URL.
    fn presigned_put_url(
        &self,
        key: &str,
        content_type: &str,
        expires_in_secs: u64,
    ) -> impl Future<Output = Result<String, Error>> + Send;

    /// Return the public URL for a key.
    fn public_url(&self, key: &str) -> String;

    /// Verify that the backend is reachable and credentials are valid.
    fn test_connection(&self) -> impl Future<Output = Result<(), Error>> + Send;
}