Crate extfsm

Source
Expand description

Implementation of a generic finite state machine with extended state. Features worth mentioning:

  • optional exit/enter transitions on states
  • each event instance can provide boxed arguments to transiton closure
  • each transition closure can return with vector of arguments that are queued at the end of outstanding events queue
  • can generate dot representation of itself, edges are grouped on color and annotated with events and optional names to provide readable, dense representation for dense graphs

§Author

Tony Przygienda, 2016

§Examples

Check out the tests in the implementation for a good example of use

§Panics

Never

§Errors

refer to Errors

§Copyrights

Copyright (c) 2017, Juniper Networks, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. This code is not an official Juniper product. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Structs§

ColorNames
ColorVariants
EntryExitKey
EntryExitTransition
stores the transition
FSM
Finite state machine type
TransitionSource
describes a transition origination point
TransitionTarget
implements the target of a transition upon an event

Enums§

DotColor
available dot colors for the transition destinations
EntryExit
types of transitions on states
Errors
Errors that can occur when running FSMs

Traits§

Annotated
RunsFSM
trait that can process events from a queue using a transition table

Type Aliases§

EntryExitTransitionFn
transition function to either enter or exit a specific state, return same as FSMTransitionFn. StateType passed in is previous state before currently entered or exited state. EventType is indicating which event causes the enter or exit. This allows to track where an FSM entered or exited a state from which can be of high interest in “stable” states of the FSM. In case of Entry on the first state it may be all None.
EventQueue
set of events to execute with according optional argument on call of transition function
OptionalFnArg
type representing an optional argument to a transition function call
TransitionFn
transition function used, takes optional argument and returns either with error or an optional set of events to be added to processing (at the end of event queue)
TransitionResult
type to be returned by all transitions an optional vector of events to be added to the FSM event queue or an error is returned