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§
Sourcefn from_events(events: &[Event<Value>]) -> Option<Self>
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.
Sourcefn apply_event(&mut self, event: &Event<Value>)
fn apply_event(&mut self, event: &Event<Value>)
Apply a single event to update state (used for incremental updates).
Sourcefn relevant_event_kinds() -> &'static [EventKind]
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.