Skip to main content

TableProvider

Trait TableProvider 

Source
pub trait TableProvider {
Show 16 methods // Required methods fn column_count(&self) -> usize; fn header(&self, index: usize) -> Option<Cow<'_, str>>; fn headers(&self) -> HeaderIter<'_> ; fn row_count(&self) -> usize; fn for_selected_rows( &self, state: &TableState, f: &mut RowCallback<'_>, ) -> Result<(), TableError>; fn for_all_rows(&self, f: &mut RowCallback<'_>) -> Result<(), TableError>; // Provided methods fn cell_at( &self, row_index: usize, col_index: usize, ) -> Result<Option<TableCell<'_>>, TableError> { ... } fn for_row_at( &self, index: usize, f: &mut RowCallback<'_>, ) -> Result<(), TableError> { ... } fn row_at(&self, index: usize) -> Result<Option<OwnedRow>, TableError> { ... } fn sort_active_rows( &self, active_rows: &mut Vec<usize>, col_index: usize, ascending: bool, ) -> Result<(), TableError> { ... } fn filter_rows( &self, state: &TableState, filters: &[(usize, Filter)], ) -> Result<Vec<usize>, TableError> { ... } fn row_hierarchy( &self, _state: &TableState, _row_index: usize, ) -> Option<RowHierarchy> { ... } fn is_tree(&self) -> bool { ... } fn row_parent(&self, _row_index: usize) -> Option<usize> { ... } fn row_children(&self, _row_index: usize) -> Vec<usize> { ... } fn row_matches( &self, _state: &TableState, _row_index: usize, _filters: &[(usize, Filter)], _highlight: Option<u8>, ) -> bool { ... }
}
Expand description

Trait implemented by datasets to back the interactive table system.

Required Methods§

Source

fn column_count(&self) -> usize

Source

fn header(&self, index: usize) -> Option<Cow<'_, str>>

Source

fn headers(&self) -> HeaderIter<'_>

Source

fn row_count(&self) -> usize

Source

fn for_selected_rows( &self, state: &TableState, f: &mut RowCallback<'_>, ) -> Result<(), TableError>

Sequentially processes each selected row with the provided callback.

Source

fn for_all_rows(&self, f: &mut RowCallback<'_>) -> Result<(), TableError>

Sequentially processes every row in the dataset.

Provided Methods§

Source

fn cell_at( &self, row_index: usize, col_index: usize, ) -> Result<Option<TableCell<'_>>, TableError>

Direct cellular random-access method.

Override this in your custom collections to achieve O(1) performance and completely bypass heap-allocation pathways during rendering.

Source

fn for_row_at( &self, index: usize, f: &mut RowCallback<'_>, ) -> Result<(), TableError>

Processes a single row by index. Override this for O(1) random access.

Source

fn row_at(&self, index: usize) -> Result<Option<OwnedRow>, TableError>

Randomly fetches a single row as an OwnedRow. This is the access path used by the rendering delegate for visible rows.

The default implementation walks the dataset sequentially (O(N)) and should be overridden for true O(1) random access whenever the backing store supports it.

Source

fn sort_active_rows( &self, active_rows: &mut Vec<usize>, col_index: usize, ascending: bool, ) -> Result<(), TableError>

Sorts the active row indices by the specified column. Uses a generic string-based fallback sorting implementation, but can be overridden.

Source

fn filter_rows( &self, state: &TableState, filters: &[(usize, Filter)], ) -> Result<Vec<usize>, TableError>

Filters all rows sequentially. Override this to implement custom parallel filtering (e.g. Rayon).

Source

fn row_hierarchy( &self, _state: &TableState, _row_index: usize, ) -> Option<RowHierarchy>

Returns tree nesting parameters for a given row. Evaluates to None by default (representing traditional non-hierarchical flat tables).

Source

fn is_tree(&self) -> bool

Returns whether this provider represents a hierarchical tree table. Returns false by default.

Source

fn row_parent(&self, _row_index: usize) -> Option<usize>

Returns the active parent row index for a given row (if any).

Source

fn row_children(&self, _row_index: usize) -> Vec<usize>

Returns the child row indices nested immediately under the specified row.

Source

fn row_matches( &self, _state: &TableState, _row_index: usize, _filters: &[(usize, Filter)], _highlight: Option<u8>, ) -> bool

Returns whether an individual row matches the currently active column filters.

Implementations§

Source§

impl dyn TableProvider + '_

Source

pub fn map_selected_rows<T, F>( &self, state: &TableState, f: F, ) -> Result<Vec<T>, TableError>
where F: FnMut(&dyn Row) -> Result<T, TableError>,

Maps over each selected row with a closure and collects the results into a flat Vector.

Source

pub fn map_first_selected_row<T, F>( &self, state: &TableState, f: F, ) -> Result<Option<T>, TableError>
where F: FnOnce(&dyn Row) -> Result<T, TableError>,

Maps only the first selected row (if any) and returns the result, stopping iteration immediately.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§