Skip to main content

reinhardt_storages/
lib.rs

1//! # reinhardt-storages
2//!
3//! Cloud storage backend abstraction for the Reinhardt framework.
4//!
5//! This crate provides a unified interface for interacting with multiple cloud storage
6//! providers (Amazon S3, Google Cloud Storage, Azure Blob Storage) and local file system.
7//!
8//! ## Features
9//!
10//! - **Unified API**: Single `StorageBackend` trait for all storage providers
11//! - **Settings-first configuration**: `StorageSettings` composes with the
12//!   Reinhardt `#[settings]` macro
13//! - **Async I/O**: All operations are asynchronous using Tokio
14//! - **Feature Flags**: Enable only the backends you need
15//! - **Temporary URLs**: Generate S3 presigned URLs, GCS V4 signed URLs, and
16//!   Azure SAS URLs for secure file sharing
17//! - **Provider boundary**: S3 uses `reinhardt-providers` for minimal HTTP and
18//!   SigV4 support instead of depending on the full AWS SDK
19//!
20//! ## Example
21//!
22//! ```rust,no_run
23//! use reinhardt_storages::{StorageSettings, create_storage_from_settings};
24//!
25//! #[tokio::main]
26//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
27//!     let settings: StorageSettings = toml::from_str(r#"
28//! backend = "local"
29//!
30//! [local]
31//! base_path = "media"
32//! "#)?;
33//!
34//!     let storage = create_storage_from_settings(&settings).await?;
35//!     storage.save("example.txt", b"Hello, world!").await?;
36//!     let content = storage.open("example.txt").await?;
37//!
38//!     Ok(())
39//! }
40//! ```
41//!
42//! ## Compatibility
43//!
44//! `StorageConfig` and provider-specific `XxxConfig` structs are deprecated.
45//! Use `StorageSettings` with `create_storage_from_settings()` for new code.
46
47#![warn(missing_docs)]
48
49pub mod backend;
50pub mod backends;
51pub mod config;
52pub mod error;
53pub mod factory;
54pub mod settings;
55
56pub use backend::StorageBackend;
57#[allow(deprecated)] // Re-export keeps the compatibility API discoverable during the 0.2 line.
58pub use config::{BackendType, StorageConfig};
59pub use error::{Result, StorageError};
60pub use factory::{create_storage, create_storage_from_settings};
61#[cfg(feature = "azure")]
62pub use settings::AzureStorageSettings;
63#[cfg(feature = "gcs")]
64pub use settings::GcsStorageSettings;
65#[cfg(feature = "local")]
66pub use settings::LocalStorageSettings;
67#[cfg(feature = "s3")]
68pub use settings::S3StorageSettings;
69pub use settings::StorageSettings;