aboutsummaryrefslogtreecommitdiff
path: root/src/version_table.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-04-08 22:00:41 +0200
committerAlex Auvolat <alex@adnab.me>2020-04-08 22:00:41 +0200
commitbacc76a057bcd90d61bfe3584bd3cdbadc748364 (patch)
treeb9a55aec2ef1fa7660bf539c02e651ea4053688c /src/version_table.rs
parentd50edcdb4f8b8ec00b1f0ffb6a3ebbb0e5afdc1f (diff)
downloadgarage-bacc76a057bcd90d61bfe3584bd3cdbadc748364.tar.gz
garage-bacc76a057bcd90d61bfe3584bd3cdbadc748364.zip
Some work in actually storing things
Diffstat (limited to 'src/version_table.rs')
-rw-r--r--src/version_table.rs59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/version_table.rs b/src/version_table.rs
new file mode 100644
index 00000000..d857ac12
--- /dev/null
+++ b/src/version_table.rs
@@ -0,0 +1,59 @@
+use std::sync::Arc;
+use serde::{Serialize, Deserialize};
+use async_trait::async_trait;
+
+use crate::data::*;
+use crate::table::*;
+use crate::membership::System;
+
+
+#[derive(Clone, Debug, Serialize, Deserialize)]
+pub struct VersionMetaKey {
+ pub bucket: String,
+ pub key: String,
+}
+
+#[derive(Clone, Debug, Serialize, Deserialize)]
+pub struct VersionMetaValue {
+ pub timestamp: u64,
+ pub uuid: UUID,
+
+ pub mime_type: String,
+ pub size: u64,
+ pub is_complete: bool,
+
+ pub data: VersionData,
+}
+
+#[derive(Clone, Debug, Serialize, Deserialize)]
+pub enum VersionData {
+ DeleteMarker,
+ Inline(#[serde(with="serde_bytes")] Vec<u8>),
+ FirstBlock(Hash),
+}
+
+pub struct VersionTable {
+ system: Arc<System>,
+}
+
+impl KeyHash for VersionMetaKey {
+ fn hash(&self) -> Hash {
+ hash(self.bucket.as_bytes())
+ }
+}
+
+impl ValueMerge for VersionMetaValue {
+ fn merge(&mut self, other: &Self) {
+ unimplemented!()
+ }
+}
+
+#[async_trait]
+impl TableFormat for VersionTable {
+ type K = VersionMetaKey;
+ type V = VersionMetaValue;
+
+ async fn updated(&self, key: &Self::K, old: Option<&Self::V>, new: &Self::V) {
+ unimplemented!()
+ }
+}