pub trait KeyedGenerator<Index>: Clerk<Index, Item: Clone + Default + PartialEq> {
type Key: Key;
// Required methods
fn update(&mut self, data: &Self::Data) -> GeneratorChanges<Index>;
fn key(&self, data: &Self::Data, index: Index) -> Option<Self::Key>;
fn generate(&self, data: &Self::Data, key: &Self::Key) -> Self::Item;
}Expand description
Interface for generators over keyed data
Required Associated Types§
Required Methods§
Sourcefn update(&mut self, data: &Self::Data) -> GeneratorChanges<Index>
fn update(&mut self, data: &Self::Data) -> GeneratorChanges<Index>
Update the generator
This is called by kas::Events::update. It should update self as
required reflecting possible data-changes and indicate through the
returned GeneratorChanges value the updates required to tokens and
views.
Note: this method is called automatically when input data changes. When
data owned or referenced by the KeyedGenerator implementation is
changed it may be necessary to explicitly update the view controller,
e.g. using ConfigCx::update.
This method may be called frequently and without changes to data.
Sourcefn key(&self, data: &Self::Data, index: Index) -> Option<Self::Key>
fn key(&self, data: &Self::Data, index: Index) -> Option<Self::Key>
Get a key for a given index, if available
This method should be fast since it may be called repeatedly.
This method is only called for index less than the result of
Clerk::len.
This may return None even when index is within the query’s range
since data may be sparse; in this case the view widget at this index
is hidden.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".