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 }
Final 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]
StateType: Clone + Eq + Hash + Sized,
EventType: Clone + Eq + Hash + Sized,
implementation of methods to contstruct the machine
fn new(
start_state: StateType,
extended_init: Box<ExtendedState>,
name: &str,
log: Logger
) -> FSM<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType>
start_state: StateType,
extended_init: Box<ExtendedState>,
name: &str,
log: Logger
) -> FSM<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType>
new FSM with an initial extended state box'ed up so it can be passed around easily
fn dotfile(
&mut self,
filename: Option<String>,
state2name: &HashMap<StateType, &'static str>,
event2name: &HashMap<EventType, &'static str>
) -> Result<(), Error>
&mut 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
fn add_transition(
&mut self,
from: TransitionSource<StateType, EventType>,
to: TransitionTarget<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType>
) -> bool
&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!
fn add_enter_transition(
&mut self,
case: (StateType, EntryExit),
trans: Box<EntryExitTransitionFn<ExtendedState, EventType, StateType, TransitionFnArguments, ErrorType>>,
name: Option<&str>
) -> bool
&mut self,
case: (StateType, EntryExit),
trans: Box<EntryExitTransitionFn<ExtendedState, EventType, StateType, TransitionFnArguments, ErrorType>>,
name: Option<&str>
) -> bool
new enter/exit transition per state executed after the transition right before the state is entered. 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!
fn name(&self) -> &String
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
fn current_state(&self) -> StateType
check current state read-only
fn events_pending(&self) -> bool
returns
- TRUE if machine has outstanding events queued to process
Trait Implementations
impl<'a, ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType> GraphWalk<'a, DotNodeKey<StateType>, DotEdgeKey<StateType, EventType>> for FSM<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType> where
StateType: Clone + PartialEq + Eq + Hash + Sized,
EventType: Clone + PartialEq + Eq + Hash + Sized,
[src]
StateType: Clone + PartialEq + Eq + Hash + Sized,
EventType: Clone + PartialEq + Eq + Hash + Sized,
graphwalk
fn nodes(&'a self) -> Nodes<'a, DotNodeKey<StateType>>
Returns all the nodes in this graph.
fn edges(&'a self) -> Edges<'a, DotEdgeKey<StateType, EventType>>
Returns all of the edges in this graph.
fn source(&self, e: &DotEdgeKey<StateType, EventType>) -> DotNodeKey<StateType>
The source node for edge
.
fn target(&self, e: &DotEdgeKey<StateType, EventType>) -> DotNodeKey<StateType>
The target node for edge
.
impl<'a, ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType> Labeller<'a, DotNodeKey<StateType>, DotEdgeKey<StateType, EventType>> for FSM<ExtendedState, StateType, EventType, TransitionFnArguments, ErrorType> where
StateType: Clone + PartialEq + Eq + Hash + Sized,
EventType: Clone + PartialEq + Eq + Hash + Sized,
[src]
StateType: Clone + PartialEq + Eq + Hash + Sized,
EventType: Clone + PartialEq + Eq + Hash + Sized,
graph labelling
fn graph_id(&'a self) -> Id<'a>
Must return a DOT compatible identifier naming the graph.
fn node_id(&'a self, n: &DotNodeKey<StateType>) -> Id<'a>
Maps n
to a unique identifier with respect to self
. The implementer is responsible for ensuring that the returned name is a valid DOT identifier. Read more
fn node_shape(&'a self, n: &DotNodeKey<StateType>) -> Option<LabelText<'a>>
Maps n
to one of the [graphviz shape
names][1]. If None
is returned, no shape
attribute is specified. Read more
fn node_style(&'a self, n: &DotNodeKey<StateType>) -> Style
Maps n
to a style that will be used in the rendered output.
fn edge_end_arrow(&'a self, _e: &DotEdgeKey<StateType, EventType>) -> Arrow
Maps e
to arrow style that will be used on the end of an edge. Defaults to normal. Read more
fn edge_start_arrow(&'a self, _e: &DotEdgeKey<StateType, EventType>) -> Arrow
Maps e
to arrow style that will be used on the end of an edge. Defaults to no arrow style. Read more
fn edge_style(&'a self, _e: &DotEdgeKey<StateType, EventType>) -> Style
Maps e
to a style that will be used in the rendered output.
fn node_label<'b>(&'b self, n: &DotNodeKey<StateType>) -> LabelText<'b>
Maps n
to a label that will be used in the rendered output. The label need not be unique, and may be the empty string; the default is just the output from node_id
. Read more
fn edge_label<'b>(
&'b self,
ek: &DotEdgeKey<StateType, EventType>
) -> LabelText<'b>
&'b self,
ek: &DotEdgeKey<StateType, EventType>
) -> LabelText<'b>
Maps e
to a label that will be used in the rendered output. The label need not be unique, and may be the empty string; the default is in fact the empty string. Read more
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,
ErrorType: Debug,
[src]
StateType: Clone + PartialEq + Eq + Hash + Debug + Sized,
EventType: Clone + PartialEq + Eq + Hash + Debug + Sized,
ErrorType: Debug,
fn add_events(
&mut self,
events: &mut Vec<(EventType, OptionalFnArg<TransitionFnArguments>)>
) -> Result<u32, Errors<EventType, StateType, ErrorType>>
&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 process_event_queue(
&mut self
) -> Result<u32, Errors<EventType, StateType, ErrorType>>
&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