aboutsummaryrefslogtreecommitdiff
path: root/src/storage
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2023-11-02 15:28:19 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2023-11-02 15:28:19 +0100
commita65f5b25894faa9802d274beb394f40062c65bae (patch)
tree990e3f3cb1a9d9eb3bbaa62bc16049ef9524d6e6 /src/storage
parent1e192f93d5bf544c82fe91fb799d77e8b5d53afe (diff)
downloadaerogramme-a65f5b25894faa9802d274beb394f40062c65bae.tar.gz
aerogramme-a65f5b25894faa9802d274beb394f40062c65bae.zip
WIP rewrite mail/incoming
Diffstat (limited to 'src/storage')
-rw-r--r--src/storage/garage.rs6
-rw-r--r--src/storage/in_memory.rs9
-rw-r--r--src/storage/mod.rs15
3 files changed, 24 insertions, 6 deletions
diff --git a/src/storage/garage.rs b/src/storage/garage.rs
index 595a57c..46da4aa 100644
--- a/src/storage/garage.rs
+++ b/src/storage/garage.rs
@@ -27,6 +27,10 @@ impl IRowStore for GrgStore {
}
impl IRowRef for GrgRef {
+ fn clone_boxed(&self) -> RowRef {
+ unimplemented!();
+ }
+
fn set_value(&self, content: Vec<u8>) -> RowValue {
unimplemented!();
}
@@ -36,7 +40,7 @@ impl IRowRef for GrgRef {
fn rm(&self) -> AsyncResult<()> {
unimplemented!();
}
- fn poll(&self) -> AsyncResult<Option<RowValue>> {
+ fn poll(&self) -> AsyncResult<RowValue> {
unimplemented!();
}
}
diff --git a/src/storage/in_memory.rs b/src/storage/in_memory.rs
index 19b55b9..144a52f 100644
--- a/src/storage/in_memory.rs
+++ b/src/storage/in_memory.rs
@@ -28,6 +28,10 @@ impl IRowStore for MemStore {
}
impl IRowRef for MemRef {
+ fn clone_boxed(&self) -> RowRef {
+ unimplemented!();
+ }
+
fn set_value(&self, content: Vec<u8>) -> RowValue {
unimplemented!();
}
@@ -37,9 +41,10 @@ impl IRowRef for MemRef {
fn rm(&self) -> AsyncResult<()> {
unimplemented!();
}
- fn poll(&self) -> AsyncResult<Option<RowValue>> {
+ fn poll(&self) -> AsyncResult<RowValue> {
async {
- Ok(None)
+ let rv: RowValue = Box::new(MemValue{});
+ Ok(rv)
}.boxed()
}
}
diff --git a/src/storage/mod.rs b/src/storage/mod.rs
index 3e66e84..c5ed1f8 100644
--- a/src/storage/mod.rs
+++ b/src/storage/mod.rs
@@ -83,12 +83,18 @@ pub type RowStore = Box<dyn IRowStore + Sync + Send>;
pub trait IRowRef
{
+ fn clone_boxed(&self) -> RowRef;
fn set_value(&self, content: Vec<u8>) -> RowValue;
fn fetch(&self) -> AsyncResult<RowValue>;
fn rm(&self) -> AsyncResult<()>;
- fn poll(&self) -> AsyncResult<Option<RowValue>>;
+ fn poll(&self) -> AsyncResult<RowValue>;
}
pub type RowRef = Box<dyn IRowRef + Send + Sync>;
+impl Clone for RowRef {
+ fn clone(&self) -> Self {
+ return self.clone_boxed()
+ }
+}
pub trait IRowValue
{
@@ -101,14 +107,15 @@ pub type RowValue = Box<dyn IRowValue + Send + Sync>;
// ------- Blob
pub trait IBlobStore
{
- fn new_blob(&self, key: &str) -> BlobRef;
- fn list(&self) -> AsyncResult<Vec<BlobRef>>;
+ fn blob(&self, key: &str) -> BlobRef;
+ fn list(&self, prefix: &str) -> AsyncResult<Vec<BlobRef>>;
}
pub type BlobStore = Box<dyn IBlobStore + Send + Sync>;
pub trait IBlobRef
{
fn set_value(&self, content: Vec<u8>) -> BlobValue;
+ fn key(&self) -> &str;
fn fetch(&self) -> AsyncResult<BlobValue>;
fn copy(&self, dst: &BlobRef) -> AsyncResult<()>;
fn rm(&self) -> AsyncResult<()>;
@@ -117,6 +124,8 @@ pub type BlobRef = Box<dyn IBlobRef + Send + Sync>;
pub trait IBlobValue {
fn to_ref(&self) -> BlobRef;
+ fn get_meta(&self, key: &str) -> Option<&[u8]>;
+ fn content(&self) -> Option<&[u8]>;
fn push(&self) -> AsyncResult<()>;
}
pub type BlobValue = Box<dyn IBlobValue + Send + Sync>;