2020-11-20 19:11:04 +00:00
|
|
|
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()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-10 11:16:57 +00:00
|
|
|
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
2020-11-20 19:11:04 +00:00
|
|
|
pub enum DeletedFilter {
|
2022-01-03 17:03:12 +00:00
|
|
|
Any,
|
2020-11-20 19:11:04 +00:00
|
|
|
Deleted,
|
|
|
|
NotDeleted,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl DeletedFilter {
|
|
|
|
pub fn apply(&self, deleted: bool) -> bool {
|
|
|
|
match self {
|
2022-01-03 17:03:12 +00:00
|
|
|
DeletedFilter::Any => true,
|
2020-11-20 19:11:04 +00:00
|
|
|
DeletedFilter::Deleted => deleted,
|
|
|
|
DeletedFilter::NotDeleted => !deleted,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-05-10 11:16:57 +00:00
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
|
|
|
pub enum EnumerationOrder {
|
|
|
|
Forward,
|
|
|
|
Reverse,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl EnumerationOrder {
|
|
|
|
pub fn from_reverse(reverse: bool) -> Self {
|
|
|
|
if reverse {
|
|
|
|
Self::Reverse
|
|
|
|
} else {
|
|
|
|
Self::Forward
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|