pub struct StateMachine { /* private fields */ }Expand description
A state machine instance
Implementations§
Source§impl StateMachine
impl StateMachine
Sourcepub fn new(initial_state: StateId, transitions: Vec<Transition>) -> Self
pub fn new(initial_state: StateId, transitions: Vec<Transition>) -> Self
Create a new state machine with an initial state and transitions
Sourcepub fn builder(initial_state: StateId) -> StateMachineBuilder
pub fn builder(initial_state: StateId) -> StateMachineBuilder
Create a builder for a state machine
Sourcepub fn current_state(&self) -> StateId
pub fn current_state(&self) -> StateId
Get the current state
Sourcepub fn clear_history(&mut self)
pub fn clear_history(&mut self)
Clear transition history
Sourcepub fn can_send(&self, event: EventId) -> bool
pub fn can_send(&self, event: EventId) -> bool
Check if an event can trigger a transition from current state
Sourcepub fn send(&mut self, event: EventId) -> StateId
pub fn send(&mut self, event: EventId) -> StateId
Send an event to the state machine, potentially triggering a transition
Auto 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