pub struct Machine<'a, S: EnumTag, E: EnumTag> { /* private fields */ }
Expand description
The Machine is the Finite State Machine, which has a current state and set of all valid transitions
Implementations§
Source§impl<'a, S: EnumTag, E: EnumTag> Machine<'a, S, E>
impl<'a, S: EnumTag, E: EnumTag> Machine<'a, S, E>
Sourcepub fn new(initial_state: S) -> Machine<'a, S, E>
pub fn new(initial_state: S) -> Machine<'a, S, E>
Constructs a new FSM with a given initial state
Sourcepub fn add_transition<F>(
&mut self,
in_state: S,
on_event: E,
next_state: S,
action: F,
) -> bool
pub fn add_transition<F>( &mut self, in_state: S, on_event: E, next_state: S, action: F, ) -> bool
Registers a new valid transition with the FSM
Sourcepub fn current_state(&self) -> S
pub fn current_state(&self) -> S
Retrieves a reference to the current state
Auto Trait Implementations§
impl<'a, S, E> Freeze for Machine<'a, S, E>where
S: Freeze,
impl<'a, S, E> !RefUnwindSafe for Machine<'a, S, E>
impl<'a, S, E> !Send for Machine<'a, S, E>
impl<'a, S, E> !Sync for Machine<'a, S, E>
impl<'a, S, E> Unpin for Machine<'a, S, E>where
S: Unpin,
impl<'a, S, E> !UnwindSafe for Machine<'a, S, E>
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