Skip to main content

run_bloq_with_hook

Function run_bloq_with_hook 

Source
pub fn run_bloq_with_hook<F>(
    bloq: &Bloq,
    shots: usize,
    seed: u64,
    hook: F,
) -> Result<VerifyReport, ExecError>
where F: FnMut(&mut Simulator, &ShotContext<'_>) -> Result<(), ExecError>,
Expand description

Run run_bloq with a per-shot hook.

The hook receives the pristine post-program simulator after the program finishes but before the shot’s state is dropped or output boundaries are measured. It is called only for non-discarded shots, with a ShotContext carrying the shot’s records, stamped selectors, and OutputLogicals.

This is the entry point for out-of-band per-shot analysis a raw record fold cannot express — chiefly logical-state fidelity of a non-Clifford output (a |T⟩ factory). A hook that mutates the simulator invalidates that shot’s observable/frame reports (but not its detectors); the no-op hook of run_bloq leaves the state untouched, so its full report stays valid.

§Errors

See ExecError; also propagates any error the hook returns.