aboutsummaryrefslogblamecommitdiff
path: root/src/version_table.rs
blob: e8360cd1c3ee4f2c820a1b324ec484f90c660e98 (plain) (tree)
1
2
3
4
5
6
7
8
9
10


                                    
                        


                    
                          

 
                                                          
























                                                     
                                                

 
                                  




                                            



                                       













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

impl TableKey for VersionMetaKey {
	fn hash(&self) -> Hash {
		hash(self.bucket.as_bytes())
	}
}

impl TableValue for VersionMetaValue {
	fn sort_key(&self) -> Vec<u8> {
		vec![]
	}
	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!()
	}
}