Packages / rupm

state-machine-tools 0.1.0

Tiny finite state machine driven by a transition table, with guards, final states and history

Install

cargo add state-machine-tools --registry rupm

In Ruststudio: Packages, search for state-machine-tools, Install.

Owner: Rust Studio. Licence: MIT OR Apache-2.0. Total downloads: 0. Published 2026-11-22.

Versions

README

# state-machine-tools

Tiny finite state machine driven by a transition table, with guards, final states and history

Add it with `rupm add state-machine-tools` (or `cargo add state-machine-tools --registry rupm`).

```rust
use state_machine_tools::StateMachine;

#[derive(Clone, PartialEq, Debug)]
enum Light { Red, Green, Yellow }
#[derive(Clone, PartialEq, Debug)]
enum Ev { Timer }

let mut m = StateMachine::new(Light::Red);
m.add_transition(Light::Red, Ev::Timer, Light::Green);
m.add_transition(Light::Green, Ev::Timer, Light::Yellow);
m.add_transition(Light::Yellow, Ev::Timer, Light::Red);

assert_eq!(m.fire(&Ev::Timer).unwrap(), &Light::Green);
assert_eq!(m.state(), &Light::Green);
```