handle_get_snapshot

Function handle_get_snapshot 

Source
pub(super) fn handle_get_snapshot(state: &mut State) -> Vec<Event>
Expand description

Phase D.1 — clone the reducer’s canonical state into a Snapshot event. Read-only; doesn’t mutate state except for bumping event_version so the snapshot’s version is monotonically distinct from prior events (subscribers applying snapshot + delta events know the snapshot is “as-of” this version).

Sorted-vec serialization (rather than HashMap-as-JSON-object) for:

  1. Deterministic ordering across snapshots (idempotent diffs in operator output, easier test assertions).
  2. Wire compatibility with Vec<(K, V)> decoders that don’t require canonical-string-keyed JSON objects.