From 0a76db1b8cf6a7d7180d35fbfae82e135e7fbf59 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Mon, 30 Oct 2023 18:07:40 +0100 Subject: [PATCH] WIP traits for the storage --- src/main.rs | 1 + src/storage/mod.rs | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/storage/mod.rs diff --git a/src/main.rs b/src/main.rs index 4ca07d0..2f6d512 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,6 +7,7 @@ mod lmtp; mod login; mod mail; mod server; +mod storage; mod time; use std::path::PathBuf; diff --git a/src/storage/mod.rs b/src/storage/mod.rs new file mode 100644 index 0000000..399a416 --- /dev/null +++ b/src/storage/mod.rs @@ -0,0 +1,32 @@ +pub trait RowStore { + fn new_row_ref(partition: &str, sort: &str) -> K; +} + +pub trait RowRef { + fn set_value(&self, content: &[u8]) -> RowValue; + async fn get(&self) -> Result; + async fn rm(&self) -> Result<(), E>; + async fn obs(&self) -> Result, ()>; +} + +pub trait RowValue { + fn row_ref(&self) -> RowRef; + fn content(&self) -> Vec; + async fn put(&self) -> Result<(), E>; +} + +/* + async fn get_many_keys(&self, keys: &[K]) -> Result, ()>; + async fn put_many_keys(&self, values: &[V]) -> Result<(), ()>; +}*/ + +pub trait BlobStore { + fn new_blob_ref(key: &str) -> BlobRef; + async fn list(&self) -> (); +} + +pub trait BlobRef { + async fn put(&self, key: &str, body: &[u8]) -> (); + async fn copy(&self, dst: &BlobRef) -> (); + async fn rm(&self, key: &str); +}