Struct extfsm::FSM [−][src]
pub struct FSM<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType> where
StateType: Clone + Eq + Hash + Sized,
EventType: Clone + Eq + Hash + Sized, { pub extended_state: RefCell<Box<ExtendedState>>, // some fields omitted }
Finite state machine type
Template parameters
ExtendedState
- provides a structure that every transition can access and stores extended stateTransitionFnArguments
- type that can be boxed as parameters to an event instanceErrorType
- Errors that transitions can generate internally
Fields
extended_state: RefCell<Box<ExtendedState>>
Methods
impl<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType> FSM<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType> where
StateType: Clone + Eq + Hash + Sized,
EventType: Clone + Eq + Hash + Sized,
[src]
impl<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType> FSM<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType> where
StateType: Clone + Eq + Hash + Sized,
EventType: Clone + Eq + Hash + Sized,
implementation of methods to contstruct the machine
pub fn new(
start_state: StateType,
extended_init: Box<ExtendedState>,
name: &str,
log: Option<Logger>
) -> Self
[src]
pub fn new(
start_state: StateType,
extended_init: Box<ExtendedState>,
name: &str,
log: Option<Logger>
) -> Self
new FSM with an initial extended state box'ed up so it can be passed around easily
pub fn flyweight(
&self,
extended_init: Box<ExtendedState>,
name: &str,
log: Option<Logger>
) -> Self
[src]
pub fn flyweight(
&self,
extended_init: Box<ExtendedState>,
name: &str,
log: Option<Logger>
) -> Self
new FSM copy sharing transitions with this instance. This allows to pull many lightweight
copies of a single FSM template
and run them as independent instances. Observe that any
transition modifications will modify all flyweights.
pub fn add_transition(
&mut self,
from: TransitionSource<StateType, EventType>,
to: TransitionTarget<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType>
) -> bool
[src]
pub fn add_transition(
&mut self,
from: TransitionSource<StateType, EventType>,
to: TransitionTarget<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType>
) -> bool
new transition
returns
- TRUE if transition has been inserted,
FALSE if a previous has been overwritten!
pub fn transitions(
&self
) -> Ref<HashMap<TransitionSource<StateType, EventType>, TransitionTarget<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType>>>
[src]
pub fn transitions(
&self
) -> Ref<HashMap<TransitionSource<StateType, EventType>, TransitionTarget<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType>>>
read only access to transition table so it can be traversed.
pub fn entry_exit_transitions(
&self
) -> Ref<HashMap<EntryExitKey<StateType>, EntryExitTransition<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType>>>
[src]
pub fn entry_exit_transitions(
&self
) -> Ref<HashMap<EntryExitKey<StateType>, EntryExitTransition<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType>>>
read only access to the entry/exit transition table.
pub fn add_enter_transition(
&mut self,
case: (StateType, EntryExit),
trans: EntryExitTransition<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType>
) -> bool
[src]
pub fn add_enter_transition(
&mut self,
case: (StateType, EntryExit),
trans: EntryExitTransition<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType>
) -> bool
new enter/exit transition per state executed after the transition right before the state is entered or called before transition on exit. If the machine remains in the same state neither the enter nor the exit transitions are called.
returns
- TRUE if transition has been inserted, FALSE if a
previous has been overwritten!
pub fn name(&self) -> &String
[src]
pub fn name(&self) -> &String
pub fn extended_state(&self) -> Ref<Box<ExtendedState>>
[src]
pub fn extended_state(&self) -> Ref<Box<ExtendedState>>
gives a read only peek into the extended state from the outside of transitions. Must be given up before running machine of course
pub fn current_state(&self) -> StateType
[src]
pub fn current_state(&self) -> StateType
check current state read-only
pub fn events_pending(&self) -> bool
[src]
pub fn events_pending(&self) -> bool
returns
- TRUE if machine has outstanding events queued to process
impl<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType> FSM<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType> where
StateType: Clone + Eq + Ord + Hash + Sized,
EventType: Clone + Eq + Ord + Hash + Sized,
[src]
impl<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType> FSM<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType> where
StateType: Clone + Eq + Ord + Hash + Sized,
EventType: Clone + Eq + Ord + Hash + Sized,
machine can be dotted if we have ordering on events & states
pub fn dotfile(
&self,
filename: Option<String>,
state2name: &HashMap<StateType, &'static str>,
event2name: &HashMap<EventType, &'static str>
) -> Result<(), Error>
[src]
pub fn dotfile(
&self,
filename: Option<String>,
state2name: &HashMap<StateType, &'static str>,
event2name: &HashMap<EventType, &'static str>
) -> Result<(), Error>
provides output of the FSM in dot format
filename
- optional filename
Trait Implementations
impl<ExtendedState, EventType, StateType, TransitionFnArguments, ErrorType> RunsFSM<EventType, StateType, TransitionFnArguments, ErrorType> for FSM<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType> where
StateType: Clone + PartialEq + Eq + Hash + Debug + Sized,
EventType: Clone + PartialEq + Eq + Hash + Debug + Sized + Debug,
ErrorType: Debug,
[src]
impl<ExtendedState, EventType, StateType, TransitionFnArguments, ErrorType> RunsFSM<EventType, StateType, TransitionFnArguments, ErrorType> for FSM<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType> where
StateType: Clone + PartialEq + Eq + Hash + Debug + Sized,
EventType: Clone + PartialEq + Eq + Hash + Debug + Sized + Debug,
ErrorType: Debug,
fn add_events(
&mut self,
events: &mut Vec<(EventType, OptionalFnArg<TransitionFnArguments>)>
) -> Result<u32, Errors<EventType, StateType, ErrorType>>
[src]
fn add_events(
&mut self,
events: &mut Vec<(EventType, OptionalFnArg<TransitionFnArguments>)>
) -> Result<u32, Errors<EventType, StateType, ErrorType>>
add events to the event queue @ the back, events are not processed
fn extend_events<I>(&mut self, events: I) where
I: IntoIterator<Item = (EventType, Option<TransitionFnArguments>)>,
[src]
fn extend_events<I>(&mut self, events: I) where
I: IntoIterator<Item = (EventType, Option<TransitionFnArguments>)>,
add events to the event queue @ the back from an iterator, events are not processed
fn process_event_queue(
&mut self
) -> Result<u32, Errors<EventType, StateType, ErrorType>>
[src]
fn process_event_queue(
&mut self
) -> Result<u32, Errors<EventType, StateType, ErrorType>>
process the whole event queue. Observe that this can generate multiple messages and queue events against the FSM itself again so don't rely which state the machine ends up in Read more
Auto Trait Implementations
impl<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType> !Send for FSM<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType>
impl<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType> !Send for FSM<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType>
impl<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType> !Sync for FSM<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType>
impl<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType> !Sync for FSM<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType>