diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2023-12-19 21:41:35 +0100 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2023-12-19 21:41:35 +0100 |
commit | 3a1f68c6bf56b572c1513a8358970536d4555078 (patch) | |
tree | 267335a0574e47961a8a76ba47bdcfb25aa5b2bb /src/storage/mod.rs | |
parent | 8bc40fa0877714aabbc6134357622ab47c628f0c (diff) | |
download | aerogramme-3a1f68c6bf56b572c1513a8358970536d4555078.tar.gz aerogramme-3a1f68c6bf56b572c1513a8358970536d4555078.zip |
better handle non existing keys
Diffstat (limited to 'src/storage/mod.rs')
-rw-r--r-- | src/storage/mod.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/storage/mod.rs b/src/storage/mod.rs index a21e07d..0fedfab 100644 --- a/src/storage/mod.rs +++ b/src/storage/mod.rs @@ -50,6 +50,11 @@ pub struct RowRef { pub uid: RowUid, pub causality: Option<String>, } +impl std::fmt::Display for RowRef { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "RowRef({}, {}, {:?})", self.uid.shard, self.uid.sort, self.causality) + } +} impl RowRef { pub fn new(shard: &str, sort: &str) -> Self { @@ -90,6 +95,11 @@ impl BlobRef { Self(key.to_string()) } } +impl std::fmt::Display for BlobRef { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "BlobRef({})", self.0) + } +} #[derive(Debug, Clone)] pub struct BlobVal { @@ -111,12 +121,23 @@ impl BlobVal { } } +#[derive(Debug)] pub enum Selector<'a> { Range { shard: &'a str, sort_begin: &'a str, sort_end: &'a str }, List (Vec<RowRef>), // list of (shard_key, sort_key) Prefix { shard: &'a str, sort_prefix: &'a str }, Single(&'a RowRef), } +impl<'a> std::fmt::Display for Selector<'a> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Range { shard, sort_begin, sort_end } => write!(f, "Range({}, [{}, {}[)", shard, sort_begin, sort_end), + Self::List(list) => write!(f, "List({:?})", list), + Self::Prefix { shard, sort_prefix } => write!(f, "Prefix({}, {})", shard, sort_prefix), + Self::Single(row_ref) => write!(f, "Single({})", row_ref), + } + } +} #[async_trait] pub trait IStore { |