1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! # Statekit
//!
//! An immutable state-transition validator for predefined workflows.
//!
//! This crate is useful when states are dynamic, configuration-driven, or stored
//! as data, allowing applications to avoid hard-coding state transitions.
//!
//! State and transition invariants are enforced while constructing the machine
//! through [`MachineBuilder`].
//!
//! # Examples
//! ```
//! use statekit::{Machine, StateError};
//!
//! fn main() -> Result<(), StateError> {
//! let machine = Machine::builder()
//! .try_allow("queued", "running")?
//! .try_allow("running", "completed")?
//! .try_allow("running", "failed")?
//! .build()?;
//!
//! assert!(machine.can_transition("queued", "running"));
//! assert!(!machine.can_transition("queued", "completed"));
//!
//! machine.validate_transition("queued", "running")?;
//!
//! for transition in machine.transitions() {
//! println!("{} -> {}", transition.source(), transition.target());
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! # Invariants
//!
//! - A machine contains at least one transition.
//! - State names may not be empty or whitespace-only.
//! - State names may not begin or end with Unicode whitespace.
//! - Self-transitions are rejected.
//! - Cycles between distinct states are permitted.
//!
//! # Additional documentation
//!
//! - [Statekit Specification](https://github.com/whitephoenixsoft/statekit/blob/main/docs/statekit-specification.md)
//! - [Migration Guide](https://github.com/whitephoenixsoft/statekit/blob/main/MIGRATION.md)
//! - [Change Log](https://github.com/whitephoenixsoft/statekit/blob/main/CHANGELOG.md)
pub use MachineBuilder;
pub use StateError;
pub use Machine;
pub use Transition;
pub use StateName;
pub use Transitions;