Trait StateRef
Source pub trait StateRef<T, U, V>{
// Required methods
fn state_ref(&self) -> Option<&V>;
fn state_mut(&mut self) -> Option<&mut V>;
}
Expand description
Trait for getting references to active states.
Will be implemented by a StateMachine for every one of its states.
Get a reference to the state, if currently active.
Returns None if the state machine is not currently in the state.
§Example
pub struct Foo;
impl Substate<Top> for Foo {}
let foo: Option<&example::Foo> = machine.state_ref();
Get a mutable reference to the state.
Returns None if the state machine is not currently in the state.
§Example
pub struct Foo;
impl Substate<Top> for Foo {}
let foo: Option<&mut example::Foo> = machine.state_mut();