pub struct StateMachine<T: StateMachineImpl> { /* private fields */ }
Expand description
Encapsulates the state and other SM data and expose transition functions.
Implementations§
Source§impl<T> StateMachine<T>where
T: StateMachineImpl,
impl<T> StateMachine<T>where
T: StateMachineImpl,
Sourcepub fn new(data: T, initial_state: T::InitialState) -> Self
pub fn new(data: T, initial_state: T::InitialState) -> Self
Create a new instance of this wrapper which encapsulates the initial state.
Sourcepub fn step(&mut self)
pub fn step(&mut self)
Only change the state, do not accept any input and do not produce any output.
Sourcepub fn consume<I: Into<T::Input>>(&mut self, input: I)
pub fn consume<I: Into<T::Input>>(&mut self, input: I)
Consume an input, do not care about the output.
Sourcepub fn relay<I: Into<T::Input>, O: From<T::Output>>(&mut self, input: I) -> O
pub fn relay<I: Into<T::Input>, O: From<T::Output>>(&mut self, input: I) -> O
Consume an input, produce an output.
pub fn can_step(&mut self) -> bool
pub fn can_produce<O>(&mut self) -> boolwhere
O: Enumerated<T::Output>,
pub fn can_consume<I>(&mut self) -> boolwhere
I: Enumerated<T::Input>,
pub fn can_relay<I, O>(&mut self) -> boolwhere
I: Enumerated<T::Input>,
O: Enumerated<T::Output>,
pub fn data(&self) -> &T
Auto Trait Implementations§
impl<T> Freeze for StateMachine<T>
impl<T> RefUnwindSafe for StateMachine<T>where
T: RefUnwindSafe,
<T as StateMachineImpl>::State: RefUnwindSafe,
impl<T> Send for StateMachine<T>
impl<T> Sync for StateMachine<T>
impl<T> Unpin for StateMachine<T>
impl<T> UnwindSafe for StateMachine<T>where
T: UnwindSafe,
<T as StateMachineImpl>::State: 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