use std::time::Duration;
use async_trait::async_trait;
use bytes::Bytes;
use chrono::{DateTime, Utc};
use url::Url;
use crate::error::BucketResult;
pub mod local;
pub use local::LocalStorage;
#[cfg(feature = "s3")]
pub mod s3;
#[cfg(feature = "s3")]
pub use s3::S3Storage;
#[cfg(feature = "test-utils")]
pub mod memory;
#[cfg(feature = "test-utils")]
pub use memory::InMemoryStorage;
#[derive(Debug, Clone)]
pub struct ObjectMeta {
pub key: String,
pub size: u64,
pub content_type: Option<String>,
pub etag: Option<String>,
pub last_modified: Option<DateTime<Utc>>,
}
#[async_trait]
pub trait ObjectStorage: Send + Sync {
async fn put(&self, key: &str, body: Bytes, content_type: &str) -> BucketResult<()>;
async fn get(&self, key: &str) -> BucketResult<Bytes>;
async fn delete(&self, key: &str) -> BucketResult<()>;
async fn head(&self, key: &str) -> BucketResult<ObjectMeta>;
async fn presigned_get(&self, key: &str, ttl: Duration) -> BucketResult<Url>;
async fn presigned_put(
&self,
key: &str,
ttl: Duration,
content_type: &str,
) -> BucketResult<Url>;
fn public_url(&self, key: &str) -> Option<Url>;
}