Trait rerun::StoreSubscriber
source · pub trait StoreSubscriber: Any + Send + Sync {
// Required methods
fn name(&self) -> String;
fn as_any(&self) -> &(dyn Any + 'static);
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static);
fn on_events(&mut self, events: &[StoreEvent]);
}
Expand description
Everything needed to build custom StoreSubscriber
s.
A StoreSubscriber
subscribes to atomic changes from all DataStore
s through StoreEvent
s.
StoreSubscriber
s can be used to build both secondary indices and trigger systems.
Required Methods§
sourcefn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Workaround for downcasting support, simply return self
:
ⓘ
fn as_any(&self) -> &dyn std::any::Any {
self
}
sourcefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Workaround for downcasting support, simply return self
:
ⓘ
fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
self
}
sourcefn on_events(&mut self, events: &[StoreEvent])
fn on_events(&mut self, events: &[StoreEvent])
The core of this trait: get notified of changes happening in all DataStore
s.
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 StoreEvent
s 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),
}
}
}