mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-20 18:12:15 +00:00
Slight refactoring to make things clearer with DeletedFilter
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
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 {
|
||||
All,
|
||||
Deleted,
|
||||
NotDeleted,
|
||||
}
|
||||
|
||||
impl DeletedFilter {
|
||||
pub fn apply(&self, deleted: bool) -> bool {
|
||||
match self {
|
||||
DeletedFilter::All => true,
|
||||
DeletedFilter::Deleted => deleted,
|
||||
DeletedFilter::NotDeleted => !deleted,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user