kellnr_storage/
storage.rs1use async_trait::async_trait;
2use bytes::Bytes;
3use chrono::{DateTime, Utc};
4
5use crate::storage_error::StorageError;
6
7pub struct ObjectWithMeta {
10 pub bytes: Bytes,
11 pub e_tag: Option<String>,
12 pub last_modified: DateTime<Utc>,
13}
14
15#[async_trait]
16pub trait Storage {
17 async fn get(&self, key: &str) -> Result<Bytes, StorageError>;
18 async fn get_with_meta(&self, key: &str) -> Result<ObjectWithMeta, StorageError>;
22 async fn put(&self, key: &str, object: Bytes) -> Result<(), StorageError>;
23 async fn put_overwrite(&self, key: &str, object: Bytes) -> Result<(), StorageError>;
27 async fn delete(&self, key: &str) -> Result<(), StorageError>;
28 async fn exists(&self, key: &str) -> Result<bool, StorageError>;
29 async fn size(&self, key: &str) -> Result<u64, StorageError>;
32 async fn list(&self, prefix: &str) -> Result<Vec<String>, StorageError>;
34}