pub trait SnapshotStore: Send + Sync {
// Required methods
async fn save(&self, snapshot: &Snapshot) -> Result<(), EngineError>;
async fn load(
&self,
stream_id: &StreamId,
) -> Result<Option<Snapshot>, EngineError>;
}Expand description
Storage contract for aggregate snapshots.
Implementations live in separate backend crates
(mako-event-store-slatedb, mako-event-store-redb, etc.).
NoopSnapshotStore is provided here for tests and deployments that do not
need snapshotting.
§Contract
savemust persist the snapshot durably before returningOk.loadmust return the most recent snapshot forstream_id, orNoneif no snapshot exists.- A snapshot must never be returned for a
stream_idif itsstate_schema_versionis not recognised by the caller — implementations are encouraged to store schema version in a queryable column/key so callers can filter by it.
§Blanket Arc implementation
Arc<S> implements SnapshotStore whenever S: SnapshotStore, so
Process<W, Arc<MyEventStore>> can accept Arc<MySnapshotStore> without
any extra wrapper.
Required Methods§
Sourceasync fn save(&self, snapshot: &Snapshot) -> Result<(), EngineError>
async fn save(&self, snapshot: &Snapshot) -> Result<(), EngineError>
Persist snapshot, replacing any previous snapshot for the same stream.
§Errors
Returns EngineError::Snapshot on storage failure.
Sourceasync fn load(
&self,
stream_id: &StreamId,
) -> Result<Option<Snapshot>, EngineError>
async fn load( &self, stream_id: &StreamId, ) -> Result<Option<Snapshot>, EngineError>
Load the most recent snapshot for stream_id.
Returns None when no snapshot exists (full replay required).
§Errors
Returns EngineError::Snapshot on storage failure.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".