statekit 0.3.1

An immutable state-machine for validating predefined transitions.
Documentation
#![deny(missing_docs)]

//! # 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
//!
//! See the project README for the specification, migration guide, changelog,
//! and benchmark documentation.
mod builder;
mod error;
mod machine;
mod transition;

mod state_name;
mod transitions;

pub use builder::MachineBuilder;
pub use error::StateError;
pub use machine::Machine;
pub use transition::Transition;

pub(crate) use state_name::StateName;
pub(crate) use transitions::Transitions;