Skip to content

Commit

Permalink
fix documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene-babichenko committed May 12, 2024
1 parent 95bf83a commit a74e958
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
19 changes: 19 additions & 0 deletions rust-fsm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a74e958

Please sign in to comment.