Trait RowSource
pub trait RowSource {
// Required methods
fn len(&self) -> usize;
fn key_at(&self, index: usize) -> Option<String>;
fn index_of(&self, key: &str) -> Option<usize>;
fn request_range(&mut self, range: Range<usize>);
fn read(
&mut self,
key: &str,
read: &mut dyn FnMut(&mut dyn Source) -> Result<(), String>,
) -> Result<bool, String>;
fn key_presenting(&self, id: &str) -> Option<String>;
fn take_changes(&mut self) -> Vec<ListModelChange<String>>;
fn has_changes(&self) -> bool;
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
Rows its host renders only when the widget shows them: a loop over ten thousand items costs the rows on screen. The host keeps the keys of every row, renders the rows the widget asks for and forgets the others, and queues what changed (rows inserted, removed or moved, and rendered rows that show something else now) for the widget to take.
Required Methods§
fn request_range(&mut self, range: Range<usize>)
fn request_range(&mut self, range: Range<usize>)
Render the rows of range not rendered yet, and forget those rendered outside it.
fn read(
&mut self,
key: &str,
read: &mut dyn FnMut(&mut dyn Source) -> Result<(), String>,
) -> Result<bool, String>
fn read( &mut self, key: &str, read: &mut dyn FnMut(&mut dyn Source) -> Result<(), String>, ) -> Result<bool, String>
Read the rendered row key as an instance of a component: Ok(false) when it is not
rendered.
§Errors
What read returned.
fn key_presenting(&self, id: &str) -> Option<String>
fn key_presenting(&self, id: &str) -> Option<String>
The key of the row showing the resource id, rendered or not.
fn take_changes(&mut self) -> Vec<ListModelChange<String>>
fn take_changes(&mut self) -> Vec<ListModelChange<String>>
What changed since it was asked last, each change against the rows the one before it left.
fn has_changes(&self) -> bool
fn has_changes(&self) -> bool
Whether changes are waiting.