diff options
author | Alex Auvolat <alex@adnab.me> | 2021-03-15 19:14:26 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2021-03-15 19:14:26 +0100 |
commit | 5ee1d956b6c7dd847a304ef524253b2e067e1245 (patch) | |
tree | 0dcaf522847fae7e105950c3f25886f5f5afa91c /src/model | |
parent | 537f652fec479c7c5676bba14c23ea6634613122 (diff) | |
download | garage-5ee1d956b6c7dd847a304ef524253b2e067e1245.tar.gz garage-5ee1d956b6c7dd847a304ef524253b2e067e1245.zip |
Allow manipulation of keys by their shorthand in the CLI
Diffstat (limited to 'src/model')
-rw-r--r-- | src/model/key_table.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/model/key_table.rs b/src/model/key_table.rs index b4ab65b6..ce5888ce 100644 --- a/src/model/key_table.rs +++ b/src/model/key_table.rs @@ -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() + } + } } } |