Finite state machines in rust; bendns fork to add types.
Diffstat (limited to 'README.md')
-rw-r--r--README.md38
1 files changed, 38 insertions, 0 deletions
diff --git a/README.md b/README.md
index 0f98d1d..0496f25 100644
--- a/README.md
+++ b/README.md
@@ -141,6 +141,44 @@ state_machine! {
The default visibility is private.
+#### Custom allphabet types
+
+You can supply your own types to use as input, output or state. All of them are
+optional: you can use only one of them or all of them at once if you want to.
+The current limitation is that you have to supply a fully qualified type path.
+
+```rust
+use rust_fsm::*;
+
+pub enum Input {
+ Successful,
+ Unsuccessful,
+ TimerTriggered,
+}
+
+pub enum State {
+ Closed,
+ HalfOpen,
+ Open,
+}
+
+pub enum Output {
+ SetupTimer,
+}
+
+state_machine! {
+ #[state_machine(input(crate::Input), state(crate::State), output(crate::Output))]
+ circuit_breaker(Closed)
+
+ Closed(Unsuccessful) => Open [SetupTimer],
+ Open(TimerTriggered) => HalfOpen,
+ HalfOpen => {
+ Successful => Closed,
+ Unsuccessful => Open [SetupTimer]
+ }
+}
+```
+
### Without DSL
The `state_machine` macro has limited capabilities (for example, a state