Trait rerun::ChunkStoreSubscriber

source ·
pub trait ChunkStoreSubscriber: 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: &[ChunkStoreEvent]);
}
Expand description

Everything needed to build custom ChunkStoreSubscribers. A ChunkStoreSubscriber subscribes to atomic changes from all ChunkStores through ChunkStoreEvents.

ChunkStoreSubscribers 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 + 'static)

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 + 'static)

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: &[ChunkStoreEvent])

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

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

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

Implementors§