pub trait EventStore: Send + Sync {
// Required methods
fn append<'life0, 'life1, 'async_trait>(
&'life0 self,
aggregate_id: &'life1 str,
version_check: VersionCheck,
events: Vec<Event>,
) -> Pin<Box<dyn Future<Output = EventStoreResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn load<'life0, 'life1, 'async_trait>(
&'life0 self,
aggregate_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = EventStoreResult<Vec<Event>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn load_from<'life0, 'life1, 'async_trait>(
&'life0 self,
aggregate_id: &'life1 str,
from_sequence: i64,
) -> Pin<Box<dyn Future<Output = EventStoreResult<Vec<Event>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn stream_all<'life0, 'async_trait>(
&'life0 self,
from_position: i64,
) -> Pin<Box<dyn Future<Output = EventStoreResult<Vec<Event>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_version<'life0, 'life1, 'async_trait>(
&'life0 self,
aggregate_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = EventStoreResult<i64>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn append_to<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
aggregate_type: &'life1 str,
aggregate_id: &'life2 str,
version_check: VersionCheck,
events: Vec<Event>,
) -> Pin<Box<dyn Future<Output = EventStoreResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn load_stream<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
aggregate_type: &'life1 str,
aggregate_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = EventStoreResult<Vec<Event>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn load_stream_from<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
aggregate_type: &'life1 str,
aggregate_id: &'life2 str,
from_sequence: i64,
) -> Pin<Box<dyn Future<Output = EventStoreResult<Vec<Event>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn get_stream_version<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
aggregate_type: &'life1 str,
aggregate_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = EventStoreResult<i64>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn save_snapshot<'life0, 'life1, 'async_trait>(
&'life0 self,
snapshot: &'life1 Snapshot,
) -> Pin<Box<dyn Future<Output = EventStoreResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn load_snapshot<'life0, 'life1, 'async_trait>(
&'life0 self,
aggregate_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = EventStoreResult<Option<Snapshot>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn load_snapshot_for<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
aggregate_type: &'life1 str,
aggregate_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = EventStoreResult<Option<Snapshot>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
}Expand description
Trait for event store implementations.
append MUST invoke validate_audit_batch before persisting (HIPAA defense
in depth). The CommandBus also validates upstream — both layers run.
Required Methods§
Sourcefn append<'life0, 'life1, 'async_trait>(
&'life0 self,
aggregate_id: &'life1 str,
version_check: VersionCheck,
events: Vec<Event>,
) -> Pin<Box<dyn Future<Output = EventStoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn append<'life0, 'life1, 'async_trait>(
&'life0 self,
aggregate_id: &'life1 str,
version_check: VersionCheck,
events: Vec<Event>,
) -> Pin<Box<dyn Future<Output = EventStoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Append events to the store for a specific aggregate.
Implementations must call validate_audit_batch(aggregate_id, &events)?
before any persistence work.
fn load<'life0, 'life1, 'async_trait>(
&'life0 self,
aggregate_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = EventStoreResult<Vec<Event>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_from<'life0, 'life1, 'async_trait>(
&'life0 self,
aggregate_id: &'life1 str,
from_sequence: i64,
) -> Pin<Box<dyn Future<Output = EventStoreResult<Vec<Event>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn stream_all<'life0, 'async_trait>(
&'life0 self,
from_position: i64,
) -> Pin<Box<dyn Future<Output = EventStoreResult<Vec<Event>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_version<'life0, 'life1, 'async_trait>(
&'life0 self,
aggregate_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = EventStoreResult<i64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Provided Methods§
Sourcefn append_to<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
aggregate_type: &'life1 str,
aggregate_id: &'life2 str,
version_check: VersionCheck,
events: Vec<Event>,
) -> Pin<Box<dyn Future<Output = EventStoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn append_to<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
aggregate_type: &'life1 str,
aggregate_id: &'life2 str,
version_check: VersionCheck,
events: Vec<Event>,
) -> Pin<Box<dyn Future<Output = EventStoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Append to the stream identified by aggregate type and instance ID.
The default preserves compatibility with stores that historically keyed
streams only by instance ID. Multi-aggregate stores override this to
enforce (aggregate_type, aggregate_id, sequence) identity.
fn load_stream<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
aggregate_type: &'life1 str,
aggregate_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = EventStoreResult<Vec<Event>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn load_stream_from<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
aggregate_type: &'life1 str,
aggregate_id: &'life2 str,
from_sequence: i64,
) -> Pin<Box<dyn Future<Output = EventStoreResult<Vec<Event>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_stream_version<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
aggregate_type: &'life1 str,
aggregate_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = EventStoreResult<i64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Sourcefn save_snapshot<'life0, 'life1, 'async_trait>(
&'life0 self,
snapshot: &'life1 Snapshot,
) -> Pin<Box<dyn Future<Output = EventStoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn save_snapshot<'life0, 'life1, 'async_trait>(
&'life0 self,
snapshot: &'life1 Snapshot,
) -> Pin<Box<dyn Future<Output = EventStoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Persist an aggregate snapshot (upsert by aggregate_id).
Default returns EventStoreError::Unsupported so stores that have not
implemented snapshotting compile unchanged and fail loudly if a caller
tries to save one.
Sourcefn load_snapshot<'life0, 'life1, 'async_trait>(
&'life0 self,
aggregate_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = EventStoreResult<Option<Snapshot>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_snapshot<'life0, 'life1, 'async_trait>(
&'life0 self,
aggregate_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = EventStoreResult<Option<Snapshot>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Load the latest snapshot for an aggregate, if one exists.
Default returns Ok(None) — safe because the caller then replays the
stream from sequence 0, which is always correct, just slower.
fn load_snapshot_for<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
aggregate_type: &'life1 str,
aggregate_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = EventStoreResult<Option<Snapshot>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".