Ecosystem Integrations

xstate-statemachine is architected to integrate seamlessly with the most popular, high-download crates in the Rust ecosystem.

The core engine (xstate-core) maintains zero external heavy dependencies and executes with sub-microsecond latency. Everything that connects to a web framework, database ORM, or message broker is decoupled into modular crates or feature flags.


๐Ÿ—บ๏ธ Pick Your Path

Find the optimal combination for your architecture:

flowchart TD
    W{Web Framework?}
    W -->|Axum| AX["Axum (xstate-axum)<br/>REST ยท SSE ยท WebSockets"]
    W -->|"Actix-web"| AC["Actix-web<br/>web::Data ยท Actor Bridge"]
    W -->|Tower| TW["Tower Service & Layer<br/>State Guard ยท Rate Limiter"]
    W -->|"None / CLI / Embedded"| DB

    AX --> DB{Persistence?}
    AC --> DB
    TW --> DB

    DB -->|"SQLx (Async SQL)"| SQLX["PostgreSQL ยท SQLite<br/>(xstate-persistence)"]
    DB -->|"SeaORM (Async ORM)"| SEA["SeaORM ActiveModel<br/>Entity State Transitions"]
    DB -->|"Diesel (Sync ORM)"| DIE["Diesel Compile-Time ORM<br/>ToSql / FromSql Mappings"]
    DB -->|Redis| RD["Redis & Redis Streams<br/>Distributed Redlock"]
    DB -->|"In-Memory / None"| EV

    SQLX --> EV{Event-Driven?}
    SEA --> EV
    DIE --> EV
    RD --> EV

    EV -->|"NATS / RabbitMQ / SQS"| BRK["Message Brokers (xstate-eda)<br/>CloudEvents 1.0 ยท Outbox"]
    EV -->|"Internal Tokio Channels"| TK["Tokio Actors & Workers<br/>Bounded Mailbox Backpressure"]

๐Ÿ“ฆ High-Download Rust Packages Supported

Crates.io PackageDownloadsEcosystem RoleIntegration GuideFeature Flag / Crate
axum35M+Tokio web frameworkAxum Guidexstate-axum / features = ["axum"]
actix-web40M+High-throughput web frameworkActix-web GuideStandalone pattern / adapter
tower70M+Universal networking middlewareTower MiddlewareUniversal service layer
sqlx45M+Async SQL toolkit (PG, SQLite)SQLx Guidefeatures = ["sqlite", "postgres"]
sea-orm15M+Async relational ORMSeaORM GuideORM ActiveModel adapter
diesel30M+Compile-time synchronous ORMDiesel GuideCustom SQL mapping types
redis35M+Caching, locks & streamsRedis Guidefeatures = ["redis", "redis-streams"]
tracing150M+Diagnostics & structured loggingTracing GuideTracingPlugin (core)
metrics25M+Metrics facade (Prometheus)Prometheus Guidefeatures = ["observability"]
validator20M+Schema & invariant validationValidation GuidePre-transition guard plugin
proptest30M+Property-based testingTesting Harnessfeatures = ["testing"]
tokio180M+Async runtime & actorsWorkers & Queuesfeatures = ["tokio"]

โšก Cross-Language Parity with Python

If you are migrating or operating a polyglot fleet with Python xstate-statemachine:

  • xstate-axum mirrors xstate_statemachine.contrib.fastapi and starlette.
  • xstate-persistence mirrors xstate_statemachine.persistence.sqlite and postgres.
  • xstate-eda mirrors xstate_statemachine.contrib.brokers (NATS, RabbitMQ, SQS, CloudEvents).
  • xstate-observability mirrors xstate_statemachine.contrib.observability.
  • xstate-agents mirrors xstate_statemachine.contrib.agents (LangGraph / PydanticAI tool loop guards).