WIP traits for the storage
Some checks reported errors
Albatros default

This commit is contained in:
Quentin 2023-10-30 18:07:40 +01:00
parent 609dde4139
commit 0a76db1b8c
Signed by: quentin
GPG key ID: E9602264D639FF68
2 changed files with 33 additions and 0 deletions

View file

@ -7,6 +7,7 @@ mod lmtp;
mod login;
mod mail;
mod server;
mod storage;
mod time;
use std::path::PathBuf;

32
src/storage/mod.rs Normal file
View file

@ -0,0 +1,32 @@
pub trait RowStore<K: RowRef, E> {
fn new_row_ref(partition: &str, sort: &str) -> K<E>;
}
pub trait RowRef {
fn set_value(&self, content: &[u8]) -> RowValue;
async fn get(&self) -> Result<RowValue, E>;
async fn rm(&self) -> Result<(), E>;
async fn obs(&self) -> Result<Option<RowValue>, ()>;
}
pub trait RowValue {
fn row_ref(&self) -> RowRef;
fn content(&self) -> Vec<u8>;
async fn put(&self) -> Result<(), E>;
}
/*
async fn get_many_keys(&self, keys: &[K]) -> Result<Vec<V>, ()>;
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);
}