Packages / rupm

rs-dev-state-machine 0.1.0

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

Install

cargo add rs-dev-state-machine --registry rupm

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

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

Versions

README

# rs-dev-state-machine

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

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

```rust
use rs_dev_state_machine::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);
```