Sub-Microsecond Zero-Allocation Fast Path
Plain microsteps execute in 106 ns p50 (>9.4M ops/s) with 0 heap allocations. Active states use FixedBitSet; identifiers use stack-inlined SmolStr; transition actions execute inline with SmallVec.
use xstate_statemachine::prelude::*;
let mut door = SyncInterpreter::new(machine, logic);
door.start()?;
let receipt = door.send("OPEN")?; // 106 ns transition
assert_eq!(receipt.state_ids(), ["door.opened"]);
XState v5 & Stately Compatible
Load JSON exported from Stately Studio directly into Rust without modification. 53 conformance fixtures verify 100% parity against Node XState.
Spawn actors as Tokio tasks with bounded mailboxes, backpressure policies (Block, DropNewest, Error), and precision cancel-safe timers.
Virtual Clock Testing
SimulatedClock advances virtual time instantaneously. Test a 72-hour saga or 30-day billing trial deterministically in 2 milliseconds without sleeping.
Ask, Don't Poll
actor.send_and_wait("PAY", Duration::from_secs(5)).await awaits the statechart transition and returns a typed Receipt the moment the microstep completes.
Receipt
state_ids=["order.paid"]
unhandled=false
actions_executed=2
duration=106ns
Durable stores for SQLite, PostgreSQL, Redis, and File. Layout v4 binary snapshots with 16-hex character topology hashes compatible with the Python library.
Expose statecharts as REST APIs, Server-Sent Events (SSE), or WebSockets via Axum. Connect the Stately Studio Inspector live over WebSocket/SSE to visualize in real time.
CloudEvents 1.0 messaging with atomic outbox commits. Native adapters for NATS JetStream, RabbitMQ, AWS SQS, and Redis Streams with dead-letter queue (DLQ) support.
Clean metric emissions via the metrics facade: transition rates, step latencies, queue depths, error counters, and active actor gauges with strict label hygiene.
#[derive(TypedEvent)], #[derive(TypedState)], and the statechart! DSL give you compile-time type-checked transitions without runtime string typos.
Run xsm validate on your JSON charts, xsm diagram to export Mermaid/PlantUML, xsm inspect --live to bridge to Stately, and xsm simulate to walk paths.
Distributed saga orchestrator with automated backward compensation rollbacks. Full-jitter exponential backoff, circuit breakers, and idempotency key caches.
The model proposes actions; the statechart decides what is permitted. Enforce per-state tool allow-lists, token budget guards, and durable human approvals.