Skip to main content

ModelTracker

Trait ModelTracker 

pub trait ModelTracker {
    // Required methods
    fn attach_peer(&self, peer: ModelPeer<'_>);
    fn track_row_count_changes(&self);
    fn track_row_data_changes(&self, row: usize);

    // Provided method
    fn track_any_change(&self, row_count: usize) { ... }
}
Expand description

This trait defines the interface that users of a model can use to track changes to a model. It is supplied via Model::model_tracker and implementation usually return a reference to its field of ModelNotify.

Required Methods§

fn attach_peer(&self, peer: ModelPeer<'_>)

Attach one peer. The peer will be notified when the model changes

fn track_row_count_changes(&self)

Register the model as a dependency to the current binding being evaluated, so that it will be notified when the model changes its size.

fn track_row_data_changes(&self, row: usize)

Register a row as a dependency to the current binding being evaluated, so that it will be notified when the value of that row changes.

Provided Methods§

fn track_any_change(&self, row_count: usize)

Register the whole model as a dependency to the current binding being evaluated, so that it will be notified of any change to the model: the row count as well as the data of any of the row_count rows.

This is equivalent to calling Self::track_row_count_changes and then Self::track_row_data_changes for every row, which is what the default implementation does, but implementations such as ModelNotify register a single dependency whose cost is independent of the number of rows.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

§

impl ModelTracker for ()

§

fn attach_peer(&self, _peer: ModelPeer<'_>)

§

fn track_row_count_changes(&self)

§

fn track_row_data_changes(&self, _row: usize)

§

fn track_any_change(&self, _row_count: usize)

Implementors§