aboutsummaryrefslogtreecommitdiff
path: root/src/version_table.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-04-09 16:16:27 +0200
committerAlex Auvolat <alex@adnab.me>2020-04-09 16:16:27 +0200
commit4c1aee42d5032066272a051687ac200e874cc13f (patch)
tree9046b13a60687fd5367dce59c246523b8585e236 /src/version_table.rs
parenta450103ed038d0838b1a1336ffd3a011abdd88a4 (diff)
downloadgarage-4c1aee42d5032066272a051687ac200e874cc13f.tar.gz
garage-4c1aee42d5032066272a051687ac200e874cc13f.zip
Reorganize table API
Diffstat (limited to 'src/version_table.rs')
-rw-r--r--src/version_table.rs32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/version_table.rs b/src/version_table.rs
index e8360cd1..1542dc42 100644
--- a/src/version_table.rs
+++ b/src/version_table.rs
@@ -8,14 +8,11 @@ use crate::table::*;
use crate::server::Garage;
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
-pub struct VersionMetaKey {
- pub bucket: String,
- pub key: String,
-}
-
#[derive(Clone, Debug, Serialize, Deserialize)]
-pub struct VersionMetaValue {
+pub struct VersionMeta {
+ pub bucket: StringKey,
+ pub key: StringKey,
+
pub timestamp: u64,
pub uuid: UUID,
@@ -37,16 +34,14 @@ pub struct VersionTable {
pub garage: RwLock<Option<Arc<Garage>>>,
}
-impl TableKey for VersionMetaKey {
- fn hash(&self) -> Hash {
- hash(self.bucket.as_bytes())
+impl Entry<StringKey, StringKey> for VersionMeta {
+ fn partition_key(&self) -> &StringKey {
+ &self.bucket
}
-}
-
-impl TableValue for VersionMetaValue {
- fn sort_key(&self) -> Vec<u8> {
- vec![]
+ fn sort_key(&self) -> &StringKey {
+ &self.key
}
+
fn merge(&mut self, other: &Self) {
unimplemented!()
}
@@ -54,10 +49,11 @@ impl TableValue for VersionMetaValue {
#[async_trait]
impl TableFormat for VersionTable {
- type K = VersionMetaKey;
- type V = VersionMetaValue;
+ type P = StringKey;
+ type S = StringKey;
+ type E = VersionMeta;
- async fn updated(&self, key: &Self::K, old: Option<&Self::V>, new: &Self::V) {
+ async fn updated(&self, old: Option<&Self::E>, new: &Self::E) {
unimplemented!()
}
}