scxml 0.2.0

W3C SCXML statechart library — parse, validate, export, and simulate Harel statecharts. Framework-agnostic, WASM-ready, rkyv zero-copy.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use crate::error::{Result, ScxmlError};
use crate::model::Statechart;

/// Export a statechart as a JSON value.
pub fn to_json(chart: &Statechart) -> Result<serde_json::Value> {
    serde_json::to_value(chart).map_err(|e| ScxmlError::Json(e.to_string()))
}

/// Export a statechart as a pretty-printed JSON string.
pub fn to_json_string(chart: &Statechart) -> Result<String> {
    serde_json::to_string_pretty(chart).map_err(|e| ScxmlError::Json(e.to_string()))
}