Struct ralf::StateMachine
[−]
[src]
pub struct StateMachine<'a, T> where
T: 'a + Copy + Clone, { /* fields omitted */ }
State machine with a state of type T
Methods
impl<'a, T> StateMachine<'a, T> where
T: 'a + Copy + Clone,
[src]
T: 'a + Copy + Clone,
pub fn new(initial_state: T) -> StateMachine<'a, T>
[src]
Create a new state machine from an initial state Note: The returned machine will be empty, so actions won't have any effects until reducers are added.
pub fn push_reducer(&mut self, reducer: &'a Reducer<T>) -> &mut Self
[src]
Add a reducer to the state machine
pub fn process(&self, a: &Action) -> &Self
[src]
Action processing logic, generate the new state from (prev_state, action) and set the internal state to the new state.
pub fn get_state(&self) -> T
[src]
Recover a copy of the state
Warning
This method will clone the entire state, and is therefore potentially expensive
Trait Implementations
impl<'a, T> Debug for StateMachine<'a, T> where
T: 'a + Copy + Clone,
[src]
T: 'a + Copy + Clone,
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<'a, T> Display for StateMachine<'a, T> where
T: 'a + Copy + Clone,
[src]
T: 'a + Copy + Clone,