Expand description
§scxml: rkyv-native W3C SCXML statechart library
A serialization, validation, and visualization library for Harel statecharts. Not a runtime executor. Compiled native types remain the fast path.
§Quick start
use scxml::{parse_xml, validate, export};
let xml = r#"
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initial="draft">
<state id="draft">
<transition event="submit" target="review"/>
</state>
<state id="review">
<transition event="approve" target="done"/>
</state>
<final id="done"/>
</scxml>
"#;
let chart = parse_xml(xml).unwrap();
validate(&chart).unwrap();
let dot = export::dot::to_dot(&chart);
assert!(dot.contains("draft"));Re-exports§
pub use parse::sanitize;pub use error::Result;pub use error::ScxmlError;pub use index::StateIndex;pub use model::Action;pub use model::ActionKind;pub use model::Binding;pub use model::DataItem;pub use model::DataModel;pub use model::HistoryKind;pub use model::IfBranch;pub use model::State;pub use model::StateKind;pub use model::Statechart;pub use model::Transition;pub use model::TransitionType;pub use resolve::ResolvedChart;pub use resolve::ResolvedState;pub use resolve::ResolvedTransition;pub use resolve::resolve;pub use stats::StatechartStats;pub use stats::stats;pub use validate::ValidationReport;pub use validate::validate;pub use validate::validate_all;pub use validate::validate_report;pub use validate::validate_report_with_hash;pub use flatten::FlatState;pub use flatten::FlatTransition;pub use flatten::flatten;
Modules§
- builder
- Ergonomic statechart construction.
Ergonomic builder for constructing
Statecharts programmatically. - diff
- Semantic comparison of two statecharts. Structural comparison of two statecharts.
- error
- Error types for parsing, validation, and simulation.
- export
- Export statecharts to DOT, Mermaid, XML, and JSON. Export statecharts to various formats (DOT, Mermaid, XML, JSON).
- flatten
- Flat state/transition lists for frontend rendering.
- index
- Pre-built state index for O(1) lookups. Pre-built index over a statechart’s state tree.
- model
- Core model types: Statechart, State, Transition, Action, DataModel. Core model types for W3C SCXML statecharts.
- parse
- Parsers for statechart definition formats. Parsers for statechart definition formats (SCXML XML, JSON) and input sanitization for untrusted sources.
- resolve
- Semantic resolution: pre-computed effective transitions and event catalogs. Semantic resolution: pre-computed effective transitions and event catalogs.
- simulate
- Lightweight test executor for event simulation. Lightweight simulation executor for testing statechart behavior.
- stats
- Summary metrics for a statechart. Statechart metrics: state counts, transition density, nesting depth.
- validate
- Structural, liveness, and semantic validation.
Constants§
- DEFAULT_
MAX_ DEPTH - Maximum nesting depth for recursive operations on the state tree.
Functions§
- max_
depth - Returns the current maximum nesting depth.
- parse_
json - Parse a JSON string into a
Statechart. - parse_
xml - Parse a W3C SCXML XML string into a
Statechart. - set_
max_ depth - Override the maximum nesting depth for recursive operations.