pub struct StateMachine { /* private fields */ }Expand description
Minimal state machine based on explicit transitions.
Implementations§
Source§impl StateMachine
impl StateMachine
Sourcepub fn add_transition(
&mut self,
transition: StateTransition,
) -> RuntimeResult<()>
pub fn add_transition( &mut self, transition: StateTransition, ) -> RuntimeResult<()>
Registers one deterministic transition, rejecting duplicate source/event pairs.
Sourcepub fn can_apply(&self, event: &EventName) -> bool
pub fn can_apply(&self, event: &EventName) -> bool
Reports whether event can be applied from the current state.
Sourcepub fn apply(&mut self, event: &EventName) -> RuntimeResult<&StateName>
pub fn apply(&mut self, event: &EventName) -> RuntimeResult<&StateName>
Applies event and returns the new current state.
Sourcepub fn transitions(&self) -> &[StateTransition]
pub fn transitions(&self) -> &[StateTransition]
Returns all transitions in registration order.
Trait Implementations§
Source§impl Clone for StateMachine
impl Clone for StateMachine
Source§fn clone(&self) -> StateMachine
fn clone(&self) -> StateMachine
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for StateMachine
impl RefUnwindSafe for StateMachine
impl Send for StateMachine
impl Sync for StateMachine
impl Unpin for StateMachine
impl UnsafeUnpin for StateMachine
impl UnwindSafe for StateMachine
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