Expand description
Handle types for simulator hooks: scripting the decisions of unsafe operators.
Every unsafe operator (like Stream::batch or
Singleton::snapshot) takes a
NonDet guard. A guard can optionally carry a hook handle,
which lets a simulation test take manual control of the non-deterministic decision made
by that operator (which elements form the next batch, which version of a piece of state
a snapshot reveals, …). See hydro_lang::sim::hooks for the test-side scripting API.
Handles are created from the FlowBuilder via
FlowBuilder::sim_hook before the
program under test is constructed, and attached to the operator they control with the
nondet!(... hook = handle) syntax. Handles are small and Copy: the same value is
passed into the program during construction and used later inside the test body to
script decisions.
This module contains only the handle types themselves (plain data), so components can
expose hookable signatures (e.g. nondet_batch: NonDet<Option<BatchHook<u32>>>, passed
directly to the batch operator it controls) without pulling
in any simulator machinery; binding a hook in a flow that is deployed rather than
simulated is harmless metadata that non-simulator backends ignore.
Structs§
- Batch
Hook - A hook handle controlling a
batchoperator over a stream ofTelements with orderingOand retry guaranteeR(mirroring the type of the stream being batched). - Ordering
Hook - A hook handle controlling an
assume_orderingoperator overTelements. - Snapshot
Hook - A hook handle controlling a
snapshotoperator over a singleton ofT.
Traits§
- SimHook
- A simulator hook handle (or a set of them) that can be created in one call to
FlowBuilder::sim_hook.