aboutsummaryrefslogtreecommitdiff
path: root/src/storage
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2023-11-17 10:46:13 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2023-11-17 10:46:13 +0100
commit7eb690e49dd995663e8ea35b1a1f5b14584b4509 (patch)
treeca6f5a3dd2be863c2d4060f791065998b446215c /src/storage
parent6da8b815b694a37d39a2be04c8e1585aac17954a (diff)
downloadaerogramme-7eb690e49dd995663e8ea35b1a1f5b14584b4509.tar.gz
aerogramme-7eb690e49dd995663e8ea35b1a1f5b14584b4509.zip
introduce an "orphan" enum
Diffstat (limited to 'src/storage')
-rw-r--r--src/storage/garage.rs9
-rw-r--r--src/storage/in_memory.rs15
-rw-r--r--src/storage/mod.rs14
3 files changed, 29 insertions, 9 deletions
diff --git a/src/storage/garage.rs b/src/storage/garage.rs
index aef9a0d..d6ac7ac 100644
--- a/src/storage/garage.rs
+++ b/src/storage/garage.rs
@@ -6,6 +6,9 @@ pub struct GrgStore {}
pub struct GrgRef {}
pub struct GrgValue {}
+#[derive(Clone, Debug)]
+pub struct GrgOrphanRowRef {}
+
impl IBuilders for GrgCreds {
fn row_store(&self) -> Result<RowStore, StorageError> {
unimplemented!();
@@ -32,13 +35,17 @@ impl IRowStore for GrgStore {
fn rm(&self, selector: Selector) -> AsyncResult<()> {
unimplemented!();
}
+
+ fn from_orphan(&self, orphan: OrphanRowRef) -> RowRef {
+ unimplemented!();
+ }
}
impl IRowRef for GrgRef {
/*fn clone_boxed(&self) -> RowRef {
unimplemented!();
}*/
- fn to_orphan(&self) -> RowRefOrphan {
+ fn to_orphan(&self) -> OrphanRowRef {
unimplemented!()
}
diff --git a/src/storage/in_memory.rs b/src/storage/in_memory.rs
index a4436e6..0bdf9b1 100644
--- a/src/storage/in_memory.rs
+++ b/src/storage/in_memory.rs
@@ -7,6 +7,9 @@ pub struct MemStore {}
pub struct MemRef {}
pub struct MemValue {}
+#[derive(Clone, Debug)]
+pub struct MemOrphanRowRef {}
+
impl IBuilders for FullMem {
fn row_store(&self) -> Result<RowStore, StorageError> {
unimplemented!();
@@ -33,16 +36,24 @@ impl IRowStore for MemStore {
fn rm(&self, selector: Selector) -> AsyncResult<()> {
unimplemented!();
}
+
+ fn from_orphan(&self, orphan: OrphanRowRef) -> RowRef {
+ unimplemented!();
+ }
}
impl IRowRef for MemRef {
+ fn to_orphan(&self) -> OrphanRowRef {
+ unimplemented!()
+ }
+
fn key(&self) -> (&str, &str) {
unimplemented!();
}
- fn clone_boxed(&self) -> RowRef {
+ /*fn clone_boxed(&self) -> RowRef {
unimplemented!();
- }
+ }*/
fn set_value(&self, content: Vec<u8>) -> RowValue {
unimplemented!();
diff --git a/src/storage/mod.rs b/src/storage/mod.rs
index 2e3c0ee..c9a49c5 100644
--- a/src/storage/mod.rs
+++ b/src/storage/mod.rs
@@ -20,6 +20,12 @@ pub enum Alternative {
}
type ConcurrentValues = Vec<Alternative>;
+#[derive(Clone, Debug)]
+pub enum OrphanRowRef {
+ Garage(garage::GrgOrphanRowRef),
+ Memory(in_memory::MemOrphanRowRef),
+}
+
pub enum Selector<'a> {
Range { shard_key: &'a str, begin: &'a str, end: &'a str },
List (Vec<(&'a str, &'a str)>), // list of (shard_key, sort_key)
@@ -81,13 +87,14 @@ pub trait IRowStore
fn row(&self, partition: &str, sort: &str) -> RowRef;
fn select(&self, selector: Selector) -> AsyncResult<Vec<RowValue>>;
fn rm(&self, selector: Selector) -> AsyncResult<()>;
+ fn from_orphan(&self, orphan: OrphanRowRef) -> RowRef;
}
pub type RowStore = Box<dyn IRowStore + Sync + Send>;
pub trait IRowRef
{
/*fn clone_boxed(&self) -> RowRef;*/
- fn to_orphan(&self) -> RowRefOrphan;
+ fn to_orphan(&self) -> OrphanRowRef;
fn key(&self) -> (&str, &str);
fn set_value(&self, content: Vec<u8>) -> RowValue;
fn fetch(&self) -> AsyncResult<RowValue>;
@@ -101,11 +108,6 @@ pub type RowRef = Box<dyn IRowRef + Send + Sync>;
}
}*/
-pub trait IRowRefOrphan
-{
- fn attach(&self, store: &RowStore) -> RowRef;
-}
-pub type RowRefOrphan = Box<dyn IRowRefOrphan + Send + Sync>;
pub trait IRowValue
{