sml/lib.rs
1//! # sml.rs
2//!
3//! A `no_std` state-machine library whose primary [`sml!`] procedural macro
4//! mirrors the `sml.cpp` transition-table DSL.
5#![doc = include_str!("../docs/dsl.md")]
6#![no_std]
7
8extern crate self as sml;
9
10pub use sml_macros::sml;
11
12pub mod utility;
13
14/// Common synchronous interface implemented by generated state machines that
15/// do not require a temporary context.
16pub trait Machine<E> {
17 /// Generated state enum.
18 type State;
19 /// Generated processing error.
20 type Error;
21
22 /// Processes one event.
23 fn process(&mut self, event: E) -> Result<&Self::State, Self::Error>;
24}
25
26/// Reports whether a state machine has reached its terminal state.
27pub trait Terminated {
28 /// Returns true after entering the generated `X` state.
29 fn is_terminated(&self) -> bool;
30}