Skip to main content

GridModel

Struct GridModel 

Source
pub struct GridModel<T> { /* private fields */ }
Expand description

Framework-independent ordering and selection over owned records.

Selection refers to an insertion index, so sorting never selects a different record.

Implementations§

Source§

impl<T> GridModel<T>

Source

pub fn new(columns: Vec<Column<T>>, rows: Vec<T>) -> Self

Source

pub fn with_row_id<K: Eq + 'static>( self, row_id: impl Fn(&T) -> K + 'static, ) -> Self

Preserve selection across replacements using an application-owned row ID. IDs must be stable and unique. A missing or duplicated selected ID clears selection. Without this callback, replacements clear selection as before. Only active/marked IDs are retained; no per-row ID index is allocated.

Source

pub fn selected_indices(&self) -> impl Iterator<Item = usize> + '_

Resident insertion indices explicitly marked for bulk actions, in insertion order. The active cursor row is independent of this set.

Source

pub fn is_row_selected(&self, index: usize) -> bool

Source

pub fn set_selected_indices( &mut self, indices: impl IntoIterator<Item = usize>, ) -> bool

Replace the bulk selection. Invalid indices are ignored.

Source

pub fn toggle_row_selection(&mut self, index: usize) -> bool

Source

pub fn clear_row_selection(&mut self) -> bool

Source

pub fn visible_len(&self) -> usize

Number of rows after filtering, independently of resident storage size.

Source

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

Filter owned rows using actual record values. Search and this predicate combine.

Source

pub fn clear_filter(&mut self)

Case-insensitive substring search across all defined formatted columns, removing terminal and bidirectional formatting controls as rendering and copying do. Formatting is evaluated for all resident rows when the query changes.

Source

pub fn rows(&self) -> &[T]

Source

pub fn sort(&self) -> Option<Sort>

Source

pub fn selected(&self) -> Option<&T>

Source

pub fn selected_index(&self) -> Option<usize>

Source

pub fn selected_position(&self) -> Option<usize>

Source

pub fn row_at(&self, position: usize) -> Option<&T>

Source

pub fn index_at(&self, position: usize) -> Option<usize>

Resolve a sorted position to the resident record’s insertion index.

Source

pub fn update_row(&mut self, index: usize, update: impl FnOnce(&mut T)) -> bool

Edit one resident record, maintaining stable sorting and selection. Returns false for an invalid index without calling update. Only the edited row is repositioned: logarithmic comparisons, with up to linear index lookup/movement. Small moves shift only the crossed span of ordering indices; the full dataset is never re-sorted.

Source

pub fn select(&mut self, position: usize) -> bool

Source

pub fn toggle_sort(&mut self, column: usize) -> bool

Cycle ascending → descending → insertion order. Returns false for unsortable columns.

Source

pub fn replace_rows(&mut self, rows: Vec<T>)

Replace records, preserving the active sort and selection when a unique matching ID is configured with Self::with_row_id.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for GridModel<T>

§

impl<T> !Send for GridModel<T>

§

impl<T> !Sync for GridModel<T>

§

impl<T> !UnwindSafe for GridModel<T>

§

impl<T> Freeze for GridModel<T>
where Vec<Column<T>>: Freeze, Vec<T>: Freeze, Option<RowIdentity<T>>: Freeze, Option<Box<dyn Fn(&T) -> bool>>: Freeze,

§

impl<T> Unpin for GridModel<T>
where Vec<Column<T>>: Unpin, Vec<T>: Unpin, Option<RowIdentity<T>>: Unpin, Option<Box<dyn Fn(&T) -> bool>>: Unpin,

§

impl<T> UnsafeUnpin for GridModel<T>
where Vec<Column<T>>: UnsafeUnpin, Vec<T>: UnsafeUnpin, Option<RowIdentity<T>>: UnsafeUnpin, Option<Box<dyn Fn(&T) -> bool>>: UnsafeUnpin,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.