Skip to main content

modo/storage/
mod.rs

1//! # modo::storage
2//!
3//! S3-compatible object storage.
4//!
5//! This module provides [`Storage`], a thin facade over S3-compatible backends
6//! (AWS S3, RustFS, MinIO, etc.). Features include upload from bytes or URL,
7//! presigned URLs, configurable ACLs, and file-size limits.
8//!
9//! ## Provides
10//!
11//! | Type | Purpose |
12//! |------|---------|
13//! | [`Storage`] | Single-bucket handle — upload, delete, public URL, presigned URL |
14//! | [`Buckets`] | Named collection of `Storage` instances for multi-bucket apps |
15//! | [`PutInput`] | Input for [`Storage::put()`] / [`Storage::put_with()`] |
16//! | [`PutFromUrlInput`] | Input for [`Storage::put_from_url()`] / [`Storage::put_from_url_with()`] |
17//! | [`PutOptions`] | Optional headers and ACL override for uploads |
18//! | [`Acl`] | Access control: `Private` (default) or `PublicRead` |
19//! | [`BucketConfig`] | Deserialisable configuration for one bucket |
20//! | [`kb()`] / [`mb()`] / [`gb()`] | Size-unit helpers (bytes conversion) |
21//!
22//! Use [`Storage::with_client()`] to share a [`reqwest::Client`] connection pool
23//! across multiple `Storage` instances or other modules.
24//!
25//! ## Quick start
26//!
27//! ```rust,no_run
28//! use modo::storage::{BucketConfig, Storage, PutInput};
29//!
30//! # fn example() -> modo::Result<()> {
31//! let mut config = BucketConfig::default();
32//! config.bucket = "my-bucket".into();
33//! config.endpoint = "https://s3.amazonaws.com".into();
34//! config.access_key = "AKIAIOSFODNN7EXAMPLE".into();
35//! config.secret_key = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY".into();
36//! config.region = Some("us-east-1".into());
37//! config.public_url = Some("https://cdn.example.com".into());
38//! config.max_file_size = Some("10mb".into());
39//! let storage = Storage::new(&config)?;
40//! # Ok(())
41//! # }
42//! ```
43//!
44//! ## Request signing
45//!
46//! All requests are signed with AWS Signature Version 4. Both path-style
47//! (`https://endpoint/bucket/key`) and virtual-hosted-style
48//! (`https://bucket.endpoint/key`) URLs are supported via the
49//! `path_style` field in [`BucketConfig`].
50
51mod backend;
52mod bridge;
53mod buckets;
54mod client;
55mod config;
56mod facade;
57mod fetch;
58pub(crate) mod memory;
59mod options;
60mod path;
61mod presign;
62mod signing;
63
64pub use buckets::Buckets;
65pub use config::BucketConfig;
66pub use config::{gb, kb, mb};
67pub use facade::{PutFromUrlInput, PutInput, Storage};
68pub use options::{Acl, PutOptions};