Crate bevy_persist

Crate bevy_persist 

Source
Expand description

Automatic persistence for Bevy resources with change detection.

This crate provides automatic saving and loading of Bevy resources, with support for multiple serialization formats and change detection.

§Features

  • Automatic Save/Load: Resources are automatically saved when modified and loaded on startup
  • Multiple Formats: Support for JSON and RON serialization formats
  • Change Detection: Only saves when resources actually change, minimizing disk I/O
  • Derive Macro: Simple #[derive(Persist)] to make any resource persistent
  • Flexible Configuration: Customize save paths, formats, and save strategies per resource

§Quick Start

use bevy::prelude::*;
use bevy_persist::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Resource, Default, Serialize, Deserialize, Persist)]
struct Settings {
    volume: f32,
    difficulty: String,
}

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugins(PersistPlugin::default())
        .init_resource::<Settings>()
        .run();
}

Re-exports§

pub use inventory;

Modules§

prelude

Structs§

PersistData
Data structure for persisting parameter values.
PersistFile
Complete persistence file format.
PersistManager
Resource that manages persistence.
PersistPlugin
Plugin for automatic persistence.
PersistRegistration
Registration data for auto-discovered Persist types.

Enums§

PersistError
Errors that can occur during persistence operations
PersistMode
Persistence mode for a resource

Traits§

Persistable
Trait for types that can be persisted.

Functions§

load_persisted
Load persisted values on startup
persist_system
Generic system to persist a resource when it changes
register_persist_type
Register a Persist type with the system.

Type Aliases§

PersistResult
Result type for persistence operations

Derive Macros§

Persist