#![warn(missing_docs)]
pub mod builder;
pub mod diff;
pub mod error;
pub mod model;
pub mod parse;
pub mod resolve;
pub mod simulate;
pub mod stats;
#[cfg(feature = "validate")]
pub mod validate;
#[cfg(feature = "xml")]
pub use parse::sanitize;
pub mod index;
#[cfg(feature = "export")]
pub mod export;
#[cfg(feature = "export")]
pub mod flatten;
#[cfg(feature = "xstate")]
pub mod xstate;
#[cfg(feature = "wasm")]
pub mod wasm;
pub const DEFAULT_MAX_DEPTH: usize = 64;
static MAX_DEPTH: std::sync::atomic::AtomicUsize =
std::sync::atomic::AtomicUsize::new(DEFAULT_MAX_DEPTH);
pub fn set_max_depth(depth: usize) {
MAX_DEPTH.store(depth, std::sync::atomic::Ordering::Relaxed);
}
pub fn max_depth() -> usize {
MAX_DEPTH.load(std::sync::atomic::Ordering::Relaxed)
}
pub use error::{Result, ScxmlError};
pub use index::StateIndex;
pub use model::{
Action, ActionKind, Binding, DataItem, DataModel, HistoryKind, IfBranch, State, StateKind,
Statechart, Transition, TransitionType,
};
pub use resolve::{ResolvedChart, ResolvedState, ResolvedTransition, resolve};
pub use stats::{StatechartStats, stats};
#[cfg(feature = "validate")]
pub use validate::{
ValidationReport, validate, validate_all, validate_report, validate_report_with_hash,
};
#[cfg(feature = "export")]
pub use flatten::{FlatState, FlatTransition, flatten};
#[cfg(feature = "xml")]
pub fn parse_xml(xml: &str) -> Result<Statechart> {
parse::xml::parse_xml(xml)
}
#[cfg(feature = "json")]
pub fn parse_json(json: &str) -> Result<Statechart> {
parse::json::parse_json(json)
}
#[cfg(feature = "xstate")]
pub fn parse_xstate(json: &str) -> Result<Statechart> {
xstate::import::parse_xstate(json)
}
#[cfg(feature = "xstate")]
pub fn to_xstate(chart: &Statechart) -> std::result::Result<String, serde_json::Error> {
xstate::export::to_xstate(chart)
}
#[cfg(feature = "rkyv")]
pub fn from_archived_bytes(
bytes: &[u8],
) -> std::result::Result<&model::statechart::ArchivedStatechart, rkyv::rancor::Error> {
rkyv::api::high::access::<model::statechart::ArchivedStatechart, rkyv::rancor::Error>(bytes)
}