Rust-SFSM 1.0.0
reddit.com·12w·
Discuss: r/rust

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...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help