pub struct FlatTreeIndex<T> { /* private fields */ }Expand description
Persistent visible-row index. It changes only when a model mutation is committed, never during layout, paint, hit-test, or a pure scroll.
Rows are depth-first in root/child order and include descendants only below expanded branches.
§Examples
use ailloli_ui_widgets::controls::{TreeItem, TreeModel, TreeMutation};
let mut model = TreeModel::new();
model.apply(TreeMutation::Insert { parent: None, index: 0, item: TreeItem::leaf(1, "file") }).unwrap();
assert_eq!(model.flat_index().rows().len(), 1);Implementations§
Source§impl<T: Eq + Hash> FlatTreeIndex<T>
impl<T: Eq + Hash> FlatTreeIndex<T>
Sourcepub fn rows(&self) -> &[FlatTreeRow<T>]
pub fn rows(&self) -> &[FlatTreeRow<T>]
Borrows all visible rows in depth-first presentation order.
§Examples
use ailloli_ui_widgets::controls::TreeModel;
assert!(TreeModel::<u8>::new().flat_index().rows().is_empty());Sourcepub fn row_of(&self, id: &T) -> Option<usize>
pub fn row_of(&self, id: &T) -> Option<usize>
Returns an item’s visible zero-based row, or None when hidden/missing.
§Examples
use ailloli_ui_widgets::controls::{TreeItem, TreeModel, TreeMutation};
let mut model = TreeModel::new();
model.apply(TreeMutation::Insert { parent: None, index: 0, item: TreeItem::leaf(9, "file") }).unwrap();
assert_eq!(model.flat_index().row_of(&9), Some(0));
assert_eq!(model.flat_index().row_of(&8), None);Sourcepub const fn revision(&self) -> u64
pub const fn revision(&self) -> u64
Returns the model revision represented by the flat index.
§Examples
use ailloli_ui_widgets::controls::TreeModel;
assert_eq!(TreeModel::<u8>::new().flat_index().revision(), 0);Sourcepub const fn rebuilds(&self) -> u64
pub const fn rebuilds(&self) -> u64
Returns the saturating count of full index materializations.
Incremental batches normally splice rows and leave this unchanged; batches of at least 1,024 mutations rebuild once at commit.
§Examples
use ailloli_ui_widgets::controls::TreeModel;
assert_eq!(TreeModel::<u8>::new().flat_index().rebuilds(), 0);Sourcepub const fn first_enabled_row(&self) -> Option<usize>
pub const fn first_enabled_row(&self) -> Option<usize>
Returns the first visible row whose item is not disabled.
§Examples
use ailloli_ui_widgets::controls::{TreeItem, TreeModel, TreeMutation};
let mut model = TreeModel::new();
model.apply(TreeMutation::Insert { parent: None, index: 0, item: TreeItem::leaf(1, "off").disabled(true) }).unwrap();
assert_eq!(model.flat_index().first_enabled_row(), None);Trait Implementations§
Source§impl<T: Clone> Clone for FlatTreeIndex<T>
impl<T: Clone> Clone for FlatTreeIndex<T>
Source§fn clone(&self) -> FlatTreeIndex<T>
fn clone(&self) -> FlatTreeIndex<T>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug> Debug for FlatTreeIndex<T>
impl<T: Debug> Debug for FlatTreeIndex<T>
Auto Trait Implementations§
impl<T> Freeze for FlatTreeIndex<T>
impl<T> RefUnwindSafe for FlatTreeIndex<T>where
T: RefUnwindSafe,
impl<T> Send for FlatTreeIndex<T>where
T: Send,
impl<T> Sync for FlatTreeIndex<T>where
T: Sync,
impl<T> Unpin for FlatTreeIndex<T>where
T: Unpin,
impl<T> UnwindSafe for FlatTreeIndex<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
§fn into_click_action(self) -> ClickAction<A>
fn into_click_action(self) -> ClickAction<A>
Implements the into_click_action helper used by this module.