Struct extfsm::FSM

source ·
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>>, /* private fields */ }
Expand description

Finite state machine type

Template parameters

  • ExtendedState - provides a structure that every transition can access and stores extended state
  • TransitionFnArguments - type that can be boxed as parameters to an event instance
  • ErrorType - Errors that transitions can generate internally

Fields§

§extended_state: RefCell<Box<ExtendedState>>

Implementations§

implementation of methods to contstruct the machine

new FSM with an initial extended state box’ed up so it can be passed around easily

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.

new transition

returns - TRUE if transition has been inserted, FALSE if a previous has been overwritten!

read only access to transition table so it can be traversed.

read only access to the entry/exit transition table.

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!

gives a read only peek into the extended state from the outside of transitions. Must be given up before running machine of course

check current state read-only

returns - TRUE if machine has outstanding events queued to process

machine can be dotted if we have ordering on events & states

provides output of the FSM in dot format

  • filename - optional filename

Trait Implementations§

add events to the event queue @ the back, events are not processed
add events to the event queue @ the back from an iterator, events are not processed
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§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.