Finite state machines in rust; bendns fork to add types.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use rust_fsm::state_machine;

state_machine! {
    /// A dummy implementation of the Circuit Breaker pattern to demonstrate
    /// capabilities of its library DSL for defining finite state machines.
    /// https://martinfowler.com/bliki/CircuitBreaker.html
    pub CircuitBreaker => pub Result => pub  Action

    Closed => Unsuccessful => Open [SetupTimer],
    Open => TimerTriggered => HalfOpen,
    HalfOpen => {
        Successful => Closed,
        Unsuccessful => Open [SetupTimer]
    }
}