diff options
Diffstat (limited to 'database/src/kv/sort/mod.rs')
| -rw-r--r-- | database/src/kv/sort/mod.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/database/src/kv/sort/mod.rs b/database/src/kv/sort/mod.rs new file mode 100644 index 0000000..403ba73 --- /dev/null +++ b/database/src/kv/sort/mod.rs @@ -0,0 +1,29 @@ +/* + This file is part of jellything (https://codeberg.org/metamuffin/jellything) + which is licensed under the GNU Affero General Public License (version 3); see /COPYING. + Copyright (C) 2026 metamuffin <metamuffin.org> +*/ + +use jellyobject::Path; + +use crate::{MultiBehaviour, Sort}; + +pub mod none; +pub mod value; + +#[derive(Hash, PartialEq, Eq)] +pub enum SortKey { + None, + Value(Path, MultiBehaviour), + Text(Path), +} + +impl Sort { + pub fn key(&self) -> SortKey { + match self { + Sort::None => SortKey::None, + Sort::Value(vs) => SortKey::Value(vs.path.clone(), vs.multi), + Sort::TextSearch(p, _) => SortKey::Text(p.to_owned()), + } + } +} |