pub struct KeyedSnapshotHook<K, V> { /* private fields */ }Expand description
A hook handle controlling a snapshot (or batch) operator over a keyed singleton
with keys K and values V.
A decision for a keyed snapshot hook picks which buffered version of each key’s state
the next tick execution observes. See hydro_lang::sim::hooks for the decisions
offered.
Implementations§
Source§impl<K, V> KeyedSnapshotHook<K, V>
impl<K, V> KeyedSnapshotHook<K, V>
Sourcepub fn reveal(
&self,
entries: impl IntoIterator<Item = (K, V)>,
) -> DecisionFuture ⓘ
Available on crate feature sim only.
pub fn reveal( &self, entries: impl IntoIterator<Item = (K, V)>, ) -> DecisionFuture ⓘ
sim only.Scripts the next tick execution to observe, for each named key, the buffered version equal to the named value: scans forward from that key’s currently-revealed version through the buffered ones and releases the first equal version, skipping over earlier versions. Keys that are not named observe their previously revealed version again (or stay absent if they have never been revealed).
This is a combined assertion and release, and the recommended way to script keyed snapshots: naming the state each key means makes any mis-synchronization fail loudly at the reveal.
§Panics
Panics immediately if entries names the same key more than once: a key observes
exactly one version per tick execution.
Sourcepub fn reveal_latest(&self) -> DecisionFuture ⓘ
Available on crate feature sim only.
pub fn reveal_latest(&self) -> DecisionFuture ⓘ
sim only.Scripts the next tick execution to observe, for every key, the newest version that
has arrived by the time the tick fires (keys with nothing newer observe their
previously revealed version again). Under fuzzing, which versions are newest
co-varies with the schedule being explored; use Self::reveal to name them
exactly.
Sourcepub fn keep(&self) -> DecisionFuture ⓘ
Available on crate feature sim only.
pub fn keep(&self) -> DecisionFuture ⓘ
sim only.Scripts the next tick execution to observe every key’s previously revealed version again.
Sourcepub fn pause(&self)
Available on crate feature sim only.
pub fn pause(&self)
sim only.Declares that buffering at this operator is intended: while paused, the hook is exempt from the missing-decision error, never causes its tick to run, and — if its tick runs anyway because other hooks feed it — contributes its “nothing new” behavior each time. Scripting any decision implicitly resumes the hook.
A pause takes its place in the script like everything else: requested while a decision is still pending, the hold begins once that decision has been consumed.
Sourcepub fn resume(&self)
Available on crate feature sim only.
pub fn resume(&self)
sim only.Ends a Self::pause (and clears Self::auto_pause mode).
Sourcepub fn auto_pause(&self)
Available on crate feature sim only.
pub fn auto_pause(&self)
sim only.Sets a standing mode where this hook only ever acts when scripted: it holds immediately, and every scripted decision leaves a fresh hold in place behind it.
This deliberately opts out of the forgotten-hook protection: if the test
forgets a step, the operator silently holds its data instead of failing. The
one auto_pause() line at the top of a test is the reviewer-visible marker
that this hook’s timing is entirely script-driven, missed steps and all.
Sourcepub async fn pause_while<Fut: Future>(&self, body: Fut) -> Fut::Output
Available on crate feature sim only.
pub async fn pause_while<Fut: Future>(&self, body: Fut) -> Fut::Output
sim only.Pauses the hook exactly for the duration of body (resuming even on panic), so
a bracketed buffering phase cannot leak a paused hook.
Sourcepub fn pause_until(
&self,
predicate: impl Fn(&KeyedSnapshotStatus) -> bool + Unpin,
) -> PauseUntilFuture<KeyedSnapshotStatus, impl Fn(&KeyedSnapshotStatus) -> bool + Unpin> ⓘ
Available on crate feature sim only.
pub fn pause_until( &self, predicate: impl Fn(&KeyedSnapshotStatus) -> bool + Unpin, ) -> PauseUntilFuture<KeyedSnapshotStatus, impl Fn(&KeyedSnapshotStatus) -> bool + Unpin> ⓘ
sim only.Pauses the hook and returns a future that resolves once the hook’s
pending-input status satisfies predicate — a synchronization point for
scripts where the right decision is not knowable upfront. The status is read
on demand at every scheduling point. After the future resolves, the hook is
unpaused; the ordinary missing-decision error applies from there on.
Sourcepub fn pause_until_versions(
&self,
n: usize,
) -> PauseUntilFuture<KeyedSnapshotStatus, impl Fn(&KeyedSnapshotStatus) -> bool + Unpin> ⓘ
Available on crate feature sim only.
pub fn pause_until_versions( &self, n: usize, ) -> PauseUntilFuture<KeyedSnapshotStatus, impl Fn(&KeyedSnapshotStatus) -> bool + Unpin> ⓘ
sim only.Pauses the hook and returns a future that resolves once at least n newer
versions are buffered (in total, across all keys); see Self::pause_until.
Trait Implementations§
Source§impl<K, V> Clone for KeyedSnapshotHook<K, V>
impl<K, V> Clone for KeyedSnapshotHook<K, V>
impl<K, V> Copy for KeyedSnapshotHook<K, V>
Source§impl<K, V> Debug for KeyedSnapshotHook<K, V>
impl<K, V> Debug for KeyedSnapshotHook<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for KeyedSnapshotHook<K, V>
impl<K, V> RefUnwindSafe for KeyedSnapshotHook<K, V>
impl<K, V> Send for KeyedSnapshotHook<K, V>
impl<K, V> Sync for KeyedSnapshotHook<K, V>
impl<K, V> Unpin for KeyedSnapshotHook<K, V>
impl<K, V> UnsafeUnpin for KeyedSnapshotHook<K, V>
impl<K, V> UnwindSafe for KeyedSnapshotHook<K, V>
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