pub trait TableModel {
// Required methods
fn row_count(&self) -> usize;
fn cell(&self, row: usize, col: usize) -> Cow<'_, str>;
fn row_key(&self, row: usize) -> RowKey;
// Provided methods
fn sort_key(&self, row: usize, col: usize) -> SortKey { ... }
fn row_role(&self, _row: usize) -> Option<Role> { ... }
fn set_cell(
&mut self,
_row: usize,
_col: usize,
_text: &str,
) -> Result<(), String> { ... }
}Expand description
Required Methods§
Provided Methods§
Sourcefn sort_key(&self, row: usize, col: usize) -> SortKey
fn sort_key(&self, row: usize, col: usize) -> SortKey
Sort key of cell (row, col). The default parses the cell as a
number and falls back to its text; override it when the displayed
text is not what should sort ("10.2%", "3 days ago").
Sourcefn row_role(&self, _row: usize) -> Option<Role>
fn row_role(&self, _row: usize) -> Option<Role>
Optional theme role for the whole row (e.g. a dimmed or an error row). It replaces only the normal row colour: the focused and the selected colours still win.
Sourcefn set_cell(
&mut self,
_row: usize,
_col: usize,
_text: &str,
) -> Result<(), String>
fn set_cell( &mut self, _row: usize, _col: usize, _text: &str, ) -> Result<(), String>
Store text in cell (row, col) — a cell editor committing on an
editable column. Err(message)
refuses the text: the table shows message in an error box and keeps
the editor open. The default refuses every edit with "read-only".
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".