Skip to main content

Projection

Trait Projection 

Source
pub trait Projection: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn process(&self, event: &Event) -> Result<()>;
    fn get_state(&self, entity_id: &str) -> Option<Value>;
    fn clear(&self);

    // Provided methods
    fn snapshot(&self) -> Option<Value> { ... }
    fn restore(&self, _snapshot: &Value) -> Result<()> { ... }
}
Expand description

A projection aggregates events into a queryable view

Required Methods§

Source

fn name(&self) -> &str

Get the name of this projection

Source

fn process(&self, event: &Event) -> Result<()>

Process an event and update the projection state

Source

fn get_state(&self, entity_id: &str) -> Option<Value>

Get the current state of the projection for an entity

Source

fn clear(&self)

Clear all projection state

Provided Methods§

Source

fn snapshot(&self) -> Option<Value>

Snapshot the entire projection state for checkpointing. Returns None if the projection does not support checkpointing.

Source

fn restore(&self, _snapshot: &Value) -> Result<()>

Restore projection state from a previously saved snapshot.

Implementors§