Skip to main content

Module sim_hooks

Module sim_hooks 

Source
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§

BatchHook
A hook handle controlling a batch operator over a stream of T elements with ordering O and retry guarantee R (mirroring the type of the stream being batched).
OrderingHook
A hook handle controlling an assume_ordering operator over T elements.
SnapshotHook
A hook handle controlling a snapshot operator over a singleton of T.

Traits§

SimHook
A simulator hook handle (or a set of them) that can be created in one call to FlowBuilder::sim_hook.