mytheclipse_storage/lib.rs
1//! # mytheclipse-storage
2//!
3//! A unified storage & file system abstraction so file handling doesn't get
4//! locked to one physical storage location.
5//!
6//! - **Local disk** ([`local::LocalFileStorage`], feature `local`, default).
7//! - **S3-compatible object storage** ([`s3::S3Storage`], feature `s3`) —
8//! works with Amazon S3 and any S3-compatible endpoint, including MinIO
9//! (pass a custom endpoint via [`s3::S3Storage::connect_with_endpoint`]).
10//! - **Google Cloud Storage** ([`gcs::GcsStorage`], feature `gcs`).
11//!
12//! All operations are stream-based (an [`traits::ObjectStream`] is a boxed
13//! [`tokio::io::AsyncRead`]), so uploading/downloading a huge object never
14//! requires holding it entirely in memory.
15//!
16//! ## Example
17//!
18//! Local disk storage (`local` feature, default):
19//!
20//! ```no_run
21//! use mytheclipse_storage::{StorageDriver, bytes_stream, read_to_vec};
22//! # #[cfg(feature = "local")]
23//! # #[tokio::main]
24//! # async fn main() {
25//! use mytheclipse_storage::LocalFileStorage;
26//! # let dir = tempfile::tempdir().unwrap();
27//! let storage = LocalFileStorage::new(dir.path());
28//! storage.put("hello.txt", bytes_stream(b"hi".to_vec())).await.unwrap();
29//! let data = read_to_vec(storage.get("hello.txt").await.unwrap()).await.unwrap();
30//! assert_eq!(data, b"hi");
31//! # }
32//! # #[cfg(not(feature = "local"))]
33//! # fn main() {}
34//! ```
35
36pub mod traits;
37
38#[cfg(feature = "local")]
39pub mod local;
40
41#[cfg(feature = "s3")]
42pub mod s3;
43
44#[cfg(feature = "gcs")]
45pub mod gcs;
46
47#[cfg(feature = "multipart")]
48pub mod multipart;
49
50pub use traits::{
51 bytes_stream, read_to_vec, ObjectMeta, ObjectStream, StorageDriver, StorageError,
52};
53
54#[cfg(feature = "local")]
55pub use local::LocalFileStorage;
56
57#[cfg(feature = "s3")]
58pub use s3::S3Storage;
59
60#[cfg(feature = "gcs")]
61pub use gcs::GcsStorage;
62
63#[cfg(feature = "multipart")]
64pub use multipart::{MultipartUpload, MultipartUploadDriver, UploadPart};