diff options
Diffstat (limited to 'src/storage')
-rw-r--r-- | src/storage/garage.rs | 6 | ||||
-rw-r--r-- | src/storage/in_memory.rs | 9 | ||||
-rw-r--r-- | src/storage/mod.rs | 15 |
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>; |