Skip to main content

egui_table_kit/filter/
mod.rs

1pub mod highlight;
2pub mod search;
3
4/// A composable column filter merging search and highlight bounds.
5#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
6pub struct Filter {
7    pub search: search::Search,
8    pub highlight: Option<Option<u8>>,
9}
10
11impl Filter {
12    #[must_use]
13    pub fn matches(&self, text: &str, row_highlight: Option<u8>) -> bool {
14        if let Some(req_highlight) = self.highlight
15            && row_highlight != req_highlight
16        {
17            return false;
18        }
19        self.search.is_match(text)
20    }
21
22    #[must_use]
23    pub const fn is_empty(&self) -> bool {
24        !self.search.is_active() && self.highlight.is_none()
25    }
26}