statemachine-rs
A zero dependency crate to implement state machine.
Usage
Let's have a look at the following simple example. This example shows the state machine
can transit its number (it called current_state
in this machine)
from given string ("next") and then, it produces outputs.
use ;
You can assemble your state machine by using statemachine_rs::machine::builder::StateMachineBUilder
.
StateMachineBuilder::initial_state()
initializes the initial state of its machine.
StateMachineBuilder::transition()
defines the transition model.
Of cource we can use enum
s for representing states and inputs. Let's have a look at another example.
The following example describes if you press the button, the state turns to be On
. Otherwise, Off
.
use ;
License
MIT
Contribution
All contributions are welcome.
If you have an idea to improve this crate, create new issue or submit new pull request.
License: MIT