Skip to main content

Module snapshot

Module snapshot 

Source
Expand description

Core types for entity snapshotting.

A repo with #[es_repo(snapshot)] persists, in the same statement as the events it appends, an author-defined state S (the fold of events 1..=k) into <tbl>_snapshots. Hydration then loads S plus only the events after k in one round trip.

Structs§

SnapshotRecord
A persisted snapshot as loaded: the state plus the metadata of the events it summarises.

Enums§

NoSnapshot
The default S of EntityEvents<E, S>: this entity has no snapshot.
Replay
One item of an entity’s replay. The snapshot, when present, is the FIRST item in forward order and the LAST item in reverse order. Deliberately exhaustive — do not add #[non_exhaustive].

Constants§

NO_SNAPSHOT_FINGERPRINT
Matches no stored snapshot; binds on full-history loads and is NoSnapshot’s fingerprint.

Traits§

EsSnapshot
Implemented by #[derive(EsSnapshot)] for user state types and by hand for NoSnapshot.
GuardWithoutSnapshotClause
Reached by idempotency_guard! when a stream yields Replay::Snapshot but the guard has no snapshot: clause. Only NoSnapshot (and SnapshotRecord<NoSnapshot>) implement it, so on a real snapshot this is a compile error with the message below.
HeadSnapshot
Implemented by every entity whose repo enables snapshot.
IntoReplay
Normalises idempotency_guard! input: a plain &E stream (today’s call sites) and a replay() stream both become Replay. Do not implement for other types.