Skip to main content

TreeRowFilter

Struct TreeRowFilter 

Source
pub struct TreeRowFilter<K: ItemKey, T> { /* private fields */ }
Expand description

A reusable sort + tree-aware filter over a Vec<TreeRow<K, T>>. Build it once, apply it to each freshly-sourced row stream (e.g. inside a TreeDataSlice::set_source closure). See the module docs.

Implementations§

Source§

impl<K: ItemKey, T: 'static> TreeRowFilter<K, T>

Source

pub fn new() -> Self

An identity transform (no filter, no sort). Chain filter / sort to configure it.

Source

pub fn filter_mode(self, mode: TreeFilterMode) -> Self

Set the filter strategy (how ancestors/descendants of a match are kept). Defaults to TreeFilterMode::default().

Source

pub fn filter(self, pred: impl Fn(&T) -> bool + 'static) -> Self

Set the match predicate over the row item. A row “matches” when pred returns true; the filter_mode decides what else stays visible. With no predicate every row is kept.

Source

pub fn sort(self, cmp: impl Fn(&T, &T) -> Ordering + 'static) -> Self

Sort siblings (ascending) by a comparator on the row item. Parent/child structure is preserved — only the order within each parent changes.

Source

pub fn sort_desc(self, cmp: impl Fn(&T, &T) -> Ordering + 'static) -> Self

Sort siblings (descending) by a comparator on the row item.

Source

pub fn apply(&self, rows: Vec<TreeRow<K, T>>) -> Vec<TreeRow<K, T>>

Apply the filter + sort to an indent-ordered row stream, returning a new indent-ordered stream. O(n log n) for the sort, O(n) otherwise.

Trait Implementations§

Source§

impl<K: ItemKey, T: 'static> Default for TreeRowFilter<K, T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<K, T> !RefUnwindSafe for TreeRowFilter<K, T>

§

impl<K, T> !Send for TreeRowFilter<K, T>

§

impl<K, T> !Sync for TreeRowFilter<K, T>

§

impl<K, T> !UnwindSafe for TreeRowFilter<K, T>

§

impl<K, T> Freeze for TreeRowFilter<K, T>

§

impl<K, T> Unpin for TreeRowFilter<K, T>

§

impl<K, T> UnsafeUnpin for TreeRowFilter<K, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.