mode
A simple and effective behavioral state machine library, written in in idiomatic, 100% safe, stable Rust code.
This library provides three main types, Automaton
, Mode
, and Transition
, that facilitate the creation of
behavioral state machines. An Automaton
can be used to quickly create a state machine over a set of Mode
s that
implement some Base
type. Each struct that implements Mode
represents a distinct state in the state machine, and
the Automaton
allows function calls to be dispatched to the current Mode
by providing access to it as a Base
reference. A flexible Transition
system provides a way for the current Mode
to swap in a new state when it is
ready. The Transition
system is designed such that the current Mode
can move data from itself directly into the
Mode
being created, which can help prevent spikes in memory usage while switching from one state to the next.
Documentation
Please see docs.rs for detailed documentation.
Example
use *;
// This trait will be used as the Base type for the Automaton, defining a common interface
// for all states.
// Each state in the state machine implements both Activity (the Base type) and Mode.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contributing
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.