EventSourced

Trait EventSourced 

Source
pub trait EventSourced: Sized {
    // Required methods
    fn from_events(events: &[Event<Value>]) -> Option<Self>;
    fn apply_event(&mut self, event: &Event<Value>);
    fn relevant_event_kinds() -> &'static [EventKind];
}
Expand description

Trait for entities that can be reconstructed from their event history.

Required Methods§

Source

fn from_events(events: &[Event<Value>]) -> Option<Self>

Reconstruct entity state from a sequence of events.

Events are sorted by timestamp before processing. Returns None if the creation event is missing or the entity has been deleted.

Source

fn apply_event(&mut self, event: &Event<Value>)

Apply a single event to update state (used for incremental updates).

Source

fn relevant_event_kinds() -> &'static [EventKind]

The event kinds this entity cares about.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§