Feature flags

Cargo features across the workspace. The engine (xstate-core) has one build feature, fast-path (on by default), and is otherwise the same small, I/O-free crate. Backends and integrations are opt-in so that a program pays, in compile time and dependencies, only for what it uses, which is the same contract as the Python library’s pip install "xstate-statemachine[extra]".

The facade: xstate-statemachine

Depend on the facade and pick features; each one enables an optional dependency, adds a module of the same name (xstate_statemachine::tokio, ::persistence, …) and the matching items of xstate_statemachine::prelude. Nothing is enabled by default.

FeatureEnablesImpliesPython extra
tokioxstate-tokio: async interpreter, spawn, Interpretercore (asyncio engine)
persistencexstate-persistence: StateStore, memory and file stores, locks, persisted, durable timers, inbox, log, migrationscore (persistence)
sqliteSqliteStore, SqliteInbox, SqliteLog (and the SQLite outbox and dead-letter stores of eda, if enabled)persistencecore (stdlib sqlite3)
redisRedisStore, RedisInbox, RedisLogpersistenceredis
postgresPostgresStore, PostgresInbox, PostgresLog (sqlx, rustls)persistencesqlalchemy
edaxstate-eda: envelope, broker contract, dispatcher, outbox, dead letters, AsyncAPIpersistenceeda
redis-streamsRedisStreamsBrokeredaredis
natsNatsBroker (JetStream)edanats
rabbitmqRabbitMqBrokeredarabbitmq
sqsSqsBrokeredasqs
patternsxstate-patterns: retry, circuit breaker, saga, choreographyedacore (patterns)
observabilityxstate-observability: MetricsObserverobservability
inspectxstate-inspect: Stately Inspector protocol, JSONL, replay, SSE sinkcore (inspect)
macrosxstate-macros: TypedEvent, TypedState, statechart!the Pythonic DSL
axumxstate-axum: registry, REST, SSE, WebSocket, inspector endpointpersistence, inspectstarlette, fastapi
agentsxstate-agents: LLM agents as statechartsagents
testingxstate-testing (a skeleton today; see its README)testing
fullall of the aboveall

Examples:

# a service that persists to PostgreSQL and consumes from NATS
xstate-statemachine = { version = "0.1", features = ["tokio", "postgres", "nats", "observability"] }

# a library that only needs the engine: no features
xstate-statemachine = "0.1"

A few points:

  • sqlite is separate from persistence on purpose: it compiles a bundled copy of SQLite (a C dependency). persistence alone gives the memory and file stores.
  • The Redis, PostgreSQL and SQS features pull in sizeable dependency trees (redis, sqlx, the AWS SDK); full builds all of them.
  • Features are additive and unify across a build, like every Cargo feature.

Per-crate features

If you depend on the individual crates, these are all of their features. A crate not listed has none.

xstate-core

FeatureDefaultAdds
fast-pathyesthe single-transition microstep fast path (on unless default-features = false)

--no-default-features compiles the fast path out, so every step goes through the general microstep. The conformance suite runs both ways in CI; the two paths are also compared case-by-case by the crate’s own differential tests.

xstate-persistence

FeatureDefaultAddsDependencies
sqliteyesSqliteStore, SqliteInbox, SqliteLogrusqlite (bundled SQLite)
redisnoRedisStore, RedisInbox, RedisLogredis (tokio, connection manager, scripts)
postgresnoPostgresStore, PostgresInbox, PostgresLogsqlx (rustls, postgres), tokio

xstate-eda

FeatureDefaultAddsDependencies
sqliteyesSqliteOutboxStore, SqliteDeadLetterStore; also enables xstate-persistence/sqliterusqlite
redis-streamsnoRedisStreamsBrokerredis, tokio
natsnoNatsBrokerasync-nats, futures-util, tokio
rabbitmqnoRabbitMqBrokerlapin, tokio
sqsnoSqsBrokeraws-config, aws-sdk-sqs, tokio

xstate-patterns depends on xstate-eda and xstate-persistence with default features off, so it does not drag SQLite in.

Crates without features

xstate-tokio, xstate-testing, xstate-inspect, xstate-observability, xstate-patterns, xstate-macros, xstate-axum, xstate-agents and the xsm binary (package xstate-statemachine-cli). The xstate-conformance (test harness) and xstate-py (Python bindings) crates are not published to crates.io.

TLS and C dependencies

TLS, where a feature has it, is rustls; openssl-sys is banned in deny.toml. sqlite compiles a bundled copy of SQLite, and the rustls backends of postgres, nats, rabbitmq and sqs build ring or aws-lc-sys, so a C compiler is needed on the build machine for those features.

MSRV

The workspace declares Rust 1.88. Every feature builds on 1.88 except postgres (and therefore full, which includes it): sqlx 0.9 requires Rust 1.94, so enabling it needs a toolchain that new. The MSRV job in ci.yml checks the workspace and every other feature on 1.88 and skips postgres; the other jobs run on stable, which covers it.