mod config;
mod drivers;
mod error;
mod facade;
mod storage;
#[cfg(feature = "s3")]
pub use drivers::S3Driver;
pub use drivers::{LocalDriver, MemoryDriver};
pub use config::StorageConfig;
pub use error::Error;
pub use facade::{Disk, DiskConfig, DiskDriver, Storage};
pub use storage::{FileMetadata, PutOptions, StorageDriver, Visibility};
pub use bytes::Bytes;
pub use async_trait::async_trait;
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn test_full_workflow() {
let storage = Storage::with_config(
"memory",
vec![(
"memory",
DiskConfig::memory().with_url("https://cdn.example.com"),
)],
);
storage.put("test/file.txt", "test content").await.unwrap();
assert!(storage.exists("test/file.txt").await.unwrap());
let contents = storage.get_string("test/file.txt").await.unwrap();
assert_eq!(contents, "test content");
let url = storage.url("test/file.txt").await.unwrap();
assert_eq!(url, "https://cdn.example.com/test/file.txt");
storage.delete("test/file.txt").await.unwrap();
assert!(!storage.exists("test/file.txt").await.unwrap());
}
}