pub struct NonDet<H = ()> { /* private fields */ }Expand description
A non-determinism guard, which documents how a source of non-determinism affects the application.
To create a non-determinism guard, use the nondet! macro, which takes in a doc comment
explaining the effects of the particular source of non-determinism, and additional
non-determinism guards that justify the form of non-determinism.
The H type parameter is the simulator hook payload the guard can carry (see
hydro_lang::sim::hooks), and defaults to () so that plain NonDet means what it
always did. A hook lets a simulation test take manual control of the non-deterministic
decisions guarded by this value:
- An unsafe operator (like
batch) takes a guard with an optional handle for that one operator, e.g.NonDet<Option<BatchHook<T>>>. A component that declares a parameter of exactly this type passes it directly to the operator it controls, documenting it in a# Non-Determinismsection of its Rustdoc. - A component that contains several unsafe operators can expose them all through one
guard by using a tuple payload, e.g.
NonDet<(Option<BatchHook<T>>, Option<SnapshotHook<S>>)>, letting the test hook some, all, or none of them. The component splits the payload withNonDet::take_hookand attaches each part to the operator it controls vianondet!(... hook = part).
Payload types implement Default (“no hook”), which is what nondet!(...) without
a hook = argument produces.
Implementations§
Source§impl<H> NonDet<H>
impl<H> NonDet<H>
Sourcepub fn take_hook(&mut self) -> Hwhere
H: Default,
pub fn take_hook(&mut self) -> Hwhere
H: Default,
Takes the hook payload out of this guard, leaving the default (“no hook”) payload in place.
This is how a component splits a composite guard across the unsafe operators it
contains: take the payload once, destructure it, and attach each part to the
operator it controls via nondet!(... hook = part). (A guard whose type already
matches a single operator’s parameter is simply passed to that operator directly.)
Taking the payload (rather than copying it) ensures a hook is only ever bound where
the binding is visible — re-wrapping a guard with nondet! never propagates a
binding.
Trait Implementations§
Auto Trait Implementations§
impl<H> Freeze for NonDet<H>where
H: Freeze,
impl<H> RefUnwindSafe for NonDet<H>where
H: RefUnwindSafe,
impl<H> Send for NonDet<H>where
H: Send,
impl<H> Sync for NonDet<H>where
H: Sync,
impl<H> Unpin for NonDet<H>where
H: Unpin,
impl<H> UnsafeUnpin for NonDet<H>where
H: UnsafeUnpin,
impl<H> UnwindSafe for NonDet<H>where
H: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more