Skip to content

Commit

Permalink
Merge pull request #17 from hashmismatch/docs
Browse files Browse the repository at this point in the history
Docs update
  • Loading branch information
rudib authored Jan 24, 2022
2 parents 0ac9a54 + cd9bd23 commit 30433be
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 11 deletions.
28 changes: 21 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
# Finny - Finite State Machines for Rust
## Finny - Hierarchical Finite State Machines for Rust

[![Crates.io][crates-badge]][crates-url]
[![Documentation](https://docs.rs/finny/badge.svg)](https://docs.rs/finny)
![Build](https://github.com/hashmismatch/finny.rs/workflows/Build/badge.svg)

## Features
### Features
* Declarative, builder API with a procedural function macro that generate the dispatcher
* Compile-time transition graph validation
* No run-time allocations required, `no_std` support
* Support for generics within the shared context
* Transition guards and actions
* FSM regions, also known as orthogonal states
* State regions, also known as orthogonal states
* Event queueing and run-to-completition execution
* Submachines, also known as Hierarchical State Machines
* Timers on states

## Example
### Example

#### Cargo.toml

```toml
[dependencies]
finny = "0.2"
```

#### Code

```rust
extern crate finny;
use finny::{finny_fsm, FsmFactory, FsmResult, decl::{BuiltFsm, FsmBuilder}};

// The context is shared between all guards, actions and transitions. Generics are supported here!
Expand All @@ -40,7 +52,7 @@ fn my_fsm(mut fsm: FsmBuilder<MyFsm, MyContext>) -> BuiltFsm {
})
.on_event::<MyEvent>()
.transition_to::<MyStateB>()
.guard(|_ev, ctx| { ctx.context.val > 0 })
.guard(|_ev, ctx, _states| { ctx.context.val > 0 })
.action(|_ev, ctx, state_a, state_b| { ctx.context.val += 1; });
fsm.state::<MyStateB>();
fsm.initial_state::<MyStateA>();
Expand All @@ -60,5 +72,7 @@ fn main() -> FsmResult<()> {
Ok(())
}
```
[crates-badge]: https://img.shields.io/crates/v/finny.svg
[crates-url]: https://crates.io/crates/finny

License: MIT OR Apache-2.0
License: MIT OR Apache-2.0
21 changes: 17 additions & 4 deletions finny/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#![cfg_attr(not(feature = "std"), no_std)]

//! # Finny - Finite State Machines for Rust
//! # Finny - Hierarchical Finite State Machines for Rust
//!
//! [![Crates.io][crates-badge]][crates-url]
//! [![Documentation](https://docs.rs/finny/badge.svg)](https://docs.rs/finny)
//! ![Build](https://github.com/hashmismatch/finny.rs/workflows/Build/badge.svg)
//!
//! ## Features
Expand All @@ -10,14 +12,23 @@
//! * No run-time allocations required, `no_std` support
//! * Support for generics within the shared context
//! * Transition guards and actions
//! * FSM regions, also known as orthogonal states
//! * State regions, also known as orthogonal states
//! * Event queueing and run-to-completition execution
//! * Submachines, also known as Hieararchical State Machines
//! * Submachines, also known as Hierarchical State Machines
//! * Timers on states
//!
//! ## Example
//!
//! ### Cargo.toml
//!
//! ```toml
//! [dependencies]
//! finny = "0.2"
//! ```
//!
//! ### Code
//!
//! ```rust
//! extern crate finny;
//! use finny::{finny_fsm, FsmFactory, FsmResult, decl::{BuiltFsm, FsmBuilder}};
//!
//! // The context is shared between all guards, actions and transitions. Generics are supported here!
Expand Down Expand Up @@ -63,6 +74,8 @@
//! Ok(())
//! }
//! ```
//! [crates-badge]: https://img.shields.io/crates/v/finny.svg
//! [crates-url]: https://crates.io/crates/finny

pub mod decl;
mod fsm;
Expand Down

0 comments on commit 30433be

Please sign in to comment.