Rust-SFSM 1.0.0
reddit.com·4h·
Discuss: r/rust
Flag this post

Yo, so I published a new major version of this lib I created and have been using for every state machine like code I work on, specially on embedded systems, with which I work the most.

Here’s de code and doc.

The rust_sfsm attribute macro can be used on structs and creates the boilerplate for any type implementing a state-like behavior.

Example

/// List of protocol states.
#[derive(Clone, Copy, Default, PartialEq)]
enum States {
#[default]
Init,
Opened,
Closed,
Locked,
}

/// List of protocol events.
enum Events {
Create,
Open,
Close,
Lock,
Unlock,
}

/// Protocol state machine context (data shared between states).
#[derive(Default)]
struct Context {
lock_counter: u16,
}

impl StateBeh...

Similar Posts

Loading similar posts...