pub struct ScenarioStateMachine<S: Copy + PartialEq> { /* private fields */ }Expand description
A generic multi-stage scenario progression.
Implementations§
Source§impl<S: Copy + PartialEq> ScenarioStateMachine<S>
impl<S: Copy + PartialEq> ScenarioStateMachine<S>
pub fn new( stages: Vec<StageConfig<S>>, terminal_stages: Vec<S>, initial: S, started_at: i64, ) -> Self
pub fn status(&self) -> ScenarioStatus
pub fn current_stage(&self) -> S
Sourcepub fn history(&self) -> &[(S, i64)]
pub fn history(&self) -> &[(S, i64)]
Every stage entered so far, oldest first, with the timestamp it was entered.
pub fn bars_in_stage(&self) -> u32
Sourcepub fn tick(&mut self)
pub fn tick(&mut self)
Advances one bar without a stage change; expires the scenario if the current stage’s
max_bars is exceeded. No-op once the machine is no longer Active.
Sourcepub fn advance(&mut self, next_stage: S, timestamp: i64) -> bool
pub fn advance(&mut self, next_stage: S, timestamp: i64) -> bool
Transitions to next_stage, resetting the per-stage bar counter. Returns false (no-op)
if the machine is not currently Active. Marks the machine Completed if next_stage is
one of the configured terminal stages.
Sourcepub fn invalidate(&mut self)
pub fn invalidate(&mut self)
Explicitly invalidates the scenario (e.g. a structural break of its setup premise).
No-op once no longer Active.
Auto Trait Implementations§
impl<S> Freeze for ScenarioStateMachine<S>
impl<S> RefUnwindSafe for ScenarioStateMachine<S>where
Vec<StageConfig<S>>: RefUnwindSafe,
Vec<S>: RefUnwindSafe,
S: RefUnwindSafe,
Vec<(S, i64)>: RefUnwindSafe,
impl<S> Send for ScenarioStateMachine<S>
impl<S> Sync for ScenarioStateMachine<S>
impl<S> Unpin for ScenarioStateMachine<S>
impl<S> UnsafeUnpin for ScenarioStateMachine<S>where
Vec<StageConfig<S>>: UnsafeUnpin,
Vec<S>: UnsafeUnpin,
S: UnsafeUnpin,
Vec<(S, i64)>: UnsafeUnpin,
impl<S> UnwindSafe for ScenarioStateMachine<S>where
Vec<StageConfig<S>>: UnwindSafe,
Vec<S>: UnwindSafe,
S: UnwindSafe,
Vec<(S, i64)>: 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
Mutably borrows from an owned value. Read more