Skip to main content

uni_plugin/traits/
collation.rs

1//! Collation (sort order) plugins.
2
3use std::cmp::Ordering;
4
5/// A custom collation — sort order for string comparison.
6pub trait CollationProvider: Send + Sync {
7    /// Collation name (`"icu.en_US"`, `"case_insensitive_ascii"`, …).
8    fn name(&self) -> &str;
9
10    /// Compare two strings under this collation.
11    fn compare(&self, a: &str, b: &str) -> Ordering;
12
13    /// Whether this collation supports substring search (for FTS / LIKE
14    /// compatibility).
15    fn supports_substring_search(&self) -> bool {
16        true
17    }
18
19    /// Canonicalize a string for index lookups (e.g., lowercase + NFC).
20    fn normalize(&self, s: &str) -> String {
21        s.to_owned()
22    }
23}