State snapshots forbevy_statemachine
A thread-safe state snapshot bridge for Bevy — expose ECS resources to Tauri IPC, WASM JavaScript, and lightyear networking without racing the schedule, as JSON or bincode.
Read state without racing
A running game's state can be read from outside the ECS world without racing the schedule, exposed to Tauri IPC, WASM JS, and lightyear networking.
What it gives you
Features
Thread-safe snapshot bridge
Exposes ECS state to external threads and consumers without blocking the Bevy schedule.
Multiple consumers
Designed for Tauri IPC, WASM JavaScript, and lightyear networking off the same snapshot.
Monotonic versioning
snapshot_version::<T>() returns a monotonic counter so consumers can detect fresh state cheaply.
Dual serialization
JSON via serde_json (default serde feature) and compact binary via the optional bincode feature.
Get started
Usage
use bevy::prelude::*;
use bevy_statemachine::{StateSnapshotPlugin, get_snapshot, get_snapshot_json};
fn main() {
App::new()
.add_plugins(StateSnapshotPlugin::<MyState>::new())
.run();
}Questions
Frequently asked
What does the bevy_statemachine crate do?
It is a thread-safe state snapshot bridge for Bevy that exposes ECS resources to external consumers such as Tauri IPC, WASM JavaScript, and lightyear networking, with both JSON and bincode serialization.
How do you read a state snapshot from bevy_statemachine?
Add StateSnapshotPlugin generic over your state type, then call get_snapshot to retrieve the latest snapshot, get_snapshot_json for a JSON string, or snapshot_version for the monotonic version counter.
What serialization formats does bevy_statemachine support?
The default serde feature provides JSON serialization via serde_json, and the optional bincode feature adds binary serialization for compact transport.