Skip to main content

Module snapshot

Module snapshot 

Source
Expand description

Snapshot capture for readout renders. See SRD-63 §6.

Each event fire captures the rendered output (both styled and ANSI-stripped) and persists to the session db’s readout_snapshots table. The latest render per (slot, subject_kind, subject_id, readout_name, lod) tuple wins — insert-or-replace upsert keeps the row count bounded by the scenario tree size.

Push 6 ships:

  • strip_ansi — utility that turns the styled byte stream into the plain-text fallback column.
  • [render_to_snapshot_strings] — convenience that takes a StringSink’s output and returns the (ansi_bytes, plain_text) pair the sqlite writer expects.
  • The [SqliteReporter::upsert_readout_snapshot] surface in nmbrs-metrics::reporters::sqlite is the actual store.

Wiring the capture into nmbrs-runtime::activity’s per-event fire sites is intentionally out of scope here — the activity-side glue lives next to the existing binder.fire() call sites and threads through whatever SqliteReporter the session already holds.

Functions§

capture
Capture a rendered body to the snapshot store. Best- effort: a None writer (snapshots disabled), lock poisoning, or “sqlite init failed” (inner Option is None) all collapse to silent no-ops — snapshot capture must never block or corrupt the readout-fire path.
lod_str
LOD → string serialised for the storage column.
strip_ansi
Strip ANSI SGR escape sequences (\x1b[...m) from a rendered string, leaving the plain text. Used to derive the body_plain column from the styled body_ansi blob.

Type Aliases§

SnapshotWriter
Handle the activity holds for snapshot writes.