Finite state machines in rust; bendns fork to add types.
fix documentation
| -rw-r--r-- | README.md | 23 | ||||
| -rw-r--r-- | rust-fsm/src/lib.rs | 19 |
2 files changed, 42 insertions, 0 deletions
@@ -120,6 +120,25 @@ attributes (e.g. `derive`, `repr`) are applied to it. Within the `state_machine` macro you must define at least one state transition. +#### Visibility + +You can specify visibility like this: + +```rust +state_machine! { + pub CircuitBreaker(Closed) + + Closed(Unsuccessful) => Open [SetupTimer], + Open(TimerTriggered) => HalfOpen, + HalfOpen => { + Successful => Closed, + Unsuccessful => Open [SetupTimer], + } +} +``` + +The default visibility is private. + ### Without DSL The `state_machine` macro has limited capabilities (for example, a state @@ -134,3 +153,7 @@ You can see an example of the Circuit Breaker state machine in the [project repository][repo]. [repo]: https://github.com/eugene-babichenko/rust-fsm/blob/master/tests/circuit_breaker.rs +[docs-badge]: https://docs.rs/rust-fsm/badge.svg +[docs-link]: https://docs.rs/rust-fsm +[crate-badge]: https://img.shields.io/crates/v/rust-fsm.svg +[crate-link]: https://crates.io/crates/rust-fsm diff --git a/rust-fsm/src/lib.rs b/rust-fsm/src/lib.rs index 337cbaa..a7a357b 100644 --- a/rust-fsm/src/lib.rs +++ b/rust-fsm/src/lib.rs @@ -117,6 +117,25 @@ //! Within the `state_machine` macro you must define at least one state //! transition. //! +//! ### Visibility +//! +//! You can specify the module visibility like this: +//! +//! ```rust +//! state_machine! { +//! pub CircuitBreaker(Closed) +//! +//! Closed(Unsuccessful) => Open [SetupTimer], +//! Open(TimerTriggered) => HalfOpen, +//! HalfOpen => { +//! Successful => Closed, +//! Unsuccessful => Open [SetupTimer], +//! } +//! } +//! ``` +//! +//! The default visibility is private. +//! //! ## Without DSL //! //! The `state_machine` macro has limited capabilities (for example, a state |