mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-25 11:56:50 +00:00
Allow manipulation of keys by their shorthand in the CLI
This commit is contained in:
+13
-2
@@ -92,13 +92,24 @@ impl CRDT for Key {
|
||||
|
||||
pub struct KeyTable;
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub enum KeyFilter {
|
||||
Deleted(DeletedFilter),
|
||||
Matches(String),
|
||||
}
|
||||
|
||||
impl TableSchema for KeyTable {
|
||||
type P = EmptyKey;
|
||||
type S = String;
|
||||
type E = Key;
|
||||
type Filter = DeletedFilter;
|
||||
type Filter = KeyFilter;
|
||||
|
||||
fn matches_filter(entry: &Self::E, filter: &Self::Filter) -> bool {
|
||||
filter.apply(entry.deleted.get())
|
||||
match filter {
|
||||
KeyFilter::Deleted(df) => df.apply(entry.deleted.get()),
|
||||
KeyFilter::Matches(pat) => {
|
||||
entry.key_id.starts_with(pat) || entry.name.get().to_lowercase() == pat.to_lowercase()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user