Skip to main content

TableProvider

Trait TableProvider 

Source
pub trait TableProvider {
    // Required methods
    fn headers(&self) -> &[&str];
    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 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 { ... }
}

Required Methods§

Source

fn headers(&self) -> &[&str]

Source

fn row_count(&self) -> usize

Source

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

Source

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

Provided Methods§

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(RowSlice<'_, '_>) -> 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(RowSlice<'_, '_>) -> 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§