pub fn step_scratch_store_observed<M, S, O>(
model: &M,
store: &mut S,
walls: &[WallSegment],
params: &M::Params,
dt: f64,
scratch: &mut Scratch,
peds_buf: &mut Vec<Pedestrian>,
observer: &mut O,
)Expand description
Observed variant of step_scratch_store: identical semantics,
plus a post-writeback callback for every agent.
observer.observe(id, &ped) is invoked once per agent, in the
same order as store.iter_ids(), with ped holding the
post-tick state that was just written back. The observer sees
the same state the next AgentStore::get call would return.
This is the production telemetry entry point: a closure that
forwards into rustsim::TelemetryPipeline::push_row (or any
other sink — CSV, Parquet, in-memory buffer, Prometheus counter)
gets per-agent per-tick coverage with zero allocation on the hot
path beyond what the sink itself may do.
Panic safety: if observer.observe panics the writeback loop
unwinds and the store is left in a partially-updated state (rows
before the panicking index are already committed; rows after it
have not yet been observed but have been written back). Callers
that cannot tolerate that should make observer.observe infallible
or forward its errors via captured state.