aboutsummaryrefslogtreecommitdiff
path: root/src/table/util.rs
diff options
context:
space:
mode:
authorQuentin <quentin@deuxfleurs.fr>2020-11-21 10:52:27 +0100
committerQuentin <quentin@deuxfleurs.fr>2020-11-21 10:52:27 +0100
commit2f6eca4ef36b662be841454774af55fe84f42d6a (patch)
treec6d7b5e5b0bedd66a4c2afacebb32760b5ed924b /src/table/util.rs
parent5b363626f4803b3e43cdb450fd6ee04ac9429c4d (diff)
parent5dc304ac41c2ae0699fbdd56117b60c517a1ad39 (diff)
downloadgarage-2f6eca4ef36b662be841454774af55fe84f42d6a.tar.gz
garage-2f6eca4ef36b662be841454774af55fe84f42d6a.zip
Merge remote-tracking branch 'origin/master' into feature/website
Diffstat (limited to 'src/table/util.rs')
-rw-r--r--src/table/util.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/table/util.rs b/src/table/util.rs
new file mode 100644
index 00000000..043a457c
--- /dev/null
+++ b/src/table/util.rs
@@ -0,0 +1,35 @@
+use serde::{Deserialize, Serialize};
+
+use garage_util::data::*;
+
+use crate::schema::*;
+
+#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
+pub struct EmptyKey;
+impl SortKey for EmptyKey {
+ fn sort_key(&self) -> &[u8] {
+ &[]
+ }
+}
+impl PartitionKey for EmptyKey {
+ fn hash(&self) -> Hash {
+ [0u8; 32].into()
+ }
+}
+
+#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
+pub enum DeletedFilter {
+ All,
+ Deleted,
+ NotDeleted,
+}
+
+impl DeletedFilter {
+ pub fn apply(&self, deleted: bool) -> bool {
+ match self {
+ DeletedFilter::All => true,
+ DeletedFilter::Deleted => deleted,
+ DeletedFilter::NotDeleted => !deleted,
+ }
+ }
+}