pub struct FSM<State, Effect>{ /* private fields */ }Expand description
Finite state machine with side effects (Mealy automata)
Implementations§
Source§impl<State, Effect> FSM<State, Effect>
impl<State, Effect> FSM<State, Effect>
Sourcepub fn new<'a>(
initial_state: State,
transition_table: HashMap<State, Vec<Transition<State, Effect>>>,
post_effect: Option<Effect>,
) -> Result<Self, FSMError<'a, State>>
pub fn new<'a>( initial_state: State, transition_table: HashMap<State, Vec<Transition<State, Effect>>>, post_effect: Option<Effect>, ) -> Result<Self, FSMError<'a, State>>
Creates new instance of FSM
- initial_state: starting state,
- transition_table: transition graph
- post_effect: post-effect
Sourcepub fn merge_effects<'a>(
&mut self,
effects_map: &HashMap<StatesConnection<State>, Vec<Effect>>,
) -> Result<(), FSMError<'a, State>>
pub fn merge_effects<'a>( &mut self, effects_map: &HashMap<StatesConnection<State>, Vec<Effect>>, ) -> Result<(), FSMError<'a, State>>
Merges effects into existing fsm for its states aligned to order of transitions for each state
- effects_map: map from pair of states (“from”, “to”) to ordered list of effects (This method is created mainly for testing, reusing the same states and transition rules (i.e. partial fsm) for different effects configurations. For typical cases, it’s recommended to build fsm from its initialization (i.e. using “new” method))
Auto Trait Implementations§
impl<State, Effect> Freeze for FSM<State, Effect>
impl<State, Effect> RefUnwindSafe for FSM<State, Effect>where
State: RefUnwindSafe,
Effect: RefUnwindSafe,
impl<State, Effect> Send for FSM<State, Effect>
impl<State, Effect> Sync for FSM<State, Effect>
impl<State, Effect> Unpin for FSM<State, Effect>
impl<State, Effect> UnwindSafe for FSM<State, Effect>where
State: UnwindSafe,
Effect: 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