Trait re_data_store::StoreSubscriber

source ·
pub trait StoreSubscriber: Any + Send + Sync {
    // Required methods
    fn name(&self) -> String;
    fn as_any(&self) -> &dyn Any;
    fn as_any_mut(&mut self) -> &mut dyn Any;
    fn on_events(&mut self, events: &[StoreEvent]);
}
Expand description

A StoreSubscriber subscribes to atomic changes from all DataStores through StoreEvents.

StoreSubscribers can be used to build both secondary indices and trigger systems.

Required Methods§

source

fn name(&self) -> String

Arbitrary name for the subscriber.

Does not need to be unique.

source

fn as_any(&self) -> &dyn Any

Workaround for downcasting support, simply return self:

fn as_any(&self) -> &dyn std::any::Any {
    self
}
source

fn as_any_mut(&mut self) -> &mut dyn Any

Workaround for downcasting support, simply return self:

fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
    self
}
source

fn on_events(&mut self, events: &[StoreEvent])

The core of this trait: get notified of changes happening in all DataStores.

This will be called automatically by the DataStore itself if the subscriber has been registered: DataStore::register_subscriber. Or you might want to feed it StoreEvents manually, depending on your use case.

§Example
fn on_events(&mut self, events: &[StoreEvent]) {
    use re_data_store::StoreDiffKind;
    for event in events {
        match event.kind {
            StoreDiffKind::Addition => println!("Row added: {}", event.row_id),
            StoreDiffKind::Deletion => println!("Row removed: {}", event.row_id),
        }
    }
}

Implementors§