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). - Keyed
Batch Hook - A hook handle controlling a
batchoperator over a keyed stream with keysK, valuesV, per-key value orderingO, and retry guaranteeR(mirroring the type of the keyed stream being batched). - Keyed
Merge Ordered Hook - A hook handle controlling a
merge_orderedoperator over keyed streams with keysKand valuesV. - Keyed
Ordering Hook - A hook handle controlling an
assume_orderingoperator over a keyed stream with keysKand valuesV. - Keyed
Snapshot Hook - A hook handle controlling a
snapshot(orbatch) operator over a keyed singleton with keysKand valuesV. - Merge
Ordered Hook - A hook handle controlling a
merge_orderedoperator over streams ofTelements. - Ordering
Hook - A hook handle controlling an
assume_orderingoperator overTelements. - Partial
Ordering Hook - A hook handle controlling an
entries_partially_orderedoperator over a keyed stream with keysKand valuesV. - 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.