aboutsummaryrefslogtreecommitdiff
path: root/src/version_table.rs
blob: 1542dc42c6a9f711763e273b48d81f6a34295603 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use std::sync::Arc;
use serde::{Serialize, Deserialize};
use async_trait::async_trait;
use tokio::sync::RwLock;

use crate::data::*;
use crate::table::*;
use crate::server::Garage;


#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct VersionMeta {
	pub bucket: StringKey,
	pub key: StringKey,

	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 {
	pub garage: RwLock<Option<Arc<Garage>>>,
}

impl Entry<StringKey, StringKey> for VersionMeta {
	fn partition_key(&self) -> &StringKey {
		&self.bucket
	}
	fn sort_key(&self) -> &StringKey {
		&self.key
	}

	fn merge(&mut self, other: &Self) {
		unimplemented!()
	}
}

#[async_trait]
impl TableFormat for VersionTable {
	type P = StringKey;
	type S = StringKey;
	type E = VersionMeta;

	async fn updated(&self, old: Option<&Self::E>, new: &Self::E) {
		unimplemented!()
	}
}