use chrono::{DateTime, Utc};
use tokio::io::AsyncRead;
pub const KEY_SEPARATOR: char = '/';
pub struct BlobInput {
pub key: String,
pub data: Box<dyn AsyncRead + Send + Unpin + 'static>,
pub size_hint: Option<u64>,
}
impl BlobInput {
pub fn new(key: impl Into<String>, data: impl AsyncRead + Send + Unpin + 'static) -> Self {
Self {
key: key.into(),
data: Box::new(data),
size_hint: None,
}
}
pub fn with_size(
key: impl Into<String>,
data: impl AsyncRead + Send + Unpin + 'static,
size: u64,
) -> Self {
Self {
key: key.into(),
data: Box::new(data),
size_hint: Some(size),
}
}
}
#[derive(Debug, Clone)]
pub struct BlobMeta {
pub key: String,
pub stored_size: u64,
pub modified_at: DateTime<Utc>,
pub etag: Option<String>,
}
impl BlobMeta {
pub(crate) fn for_key(key: &str) -> Self {
Self {
key: key.to_string(),
stored_size: 0,
modified_at: Utc::now(),
etag: None,
}
}
}
#[derive(Debug, Clone)]
pub struct PutResult {
pub blobs: Vec<BlobMeta>,
}
impl PutResult {
pub fn single(meta: BlobMeta) -> Self {
Self { blobs: vec![meta] }
}
pub fn multiple(blobs: Vec<BlobMeta>) -> Self {
Self { blobs }
}
}
#[derive(Debug, Clone)]
pub struct CleanupResult {
pub deleted_count: u64,
}
#[derive(Debug, Clone)]
pub struct RekeyResult {
pub rekeyed_count: u64,
}