garage/src/table/util.rs

36 lines
632 B
Rust
Raw Normal View History

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 {
2022-01-03 17:03:12 +00:00
Any,
Deleted,
NotDeleted,
}
impl DeletedFilter {
pub fn apply(&self, deleted: bool) -> bool {
match self {
2022-01-03 17:03:12 +00:00
DeletedFilter::Any => true,
DeletedFilter::Deleted => deleted,
DeletedFilter::NotDeleted => !deleted,
}
}
}