Skip to main content

Module save

Module save 

Source
Expand description

Save system for JRPG engine.

Provides a storage-agnostic save/load framework with CRC16 checksum validation. Game-specific data implements the SaveData trait, while platform backends implement SaveStorage. The SaveManager ties them together with multi-slot support.

§Wire format

Each save slot stores: [serialized_game_data][2-byte CRC16 checksum (LE)]

§Example

#[derive(Debug, Clone)]
struct MySave { name: String, level: u8 }

impl SaveData for MySave {
    fn serialize(&self) -> Vec<u8> { /* ... */ }
    fn deserialize(data: &[u8]) -> Result<Self, SaveError> { /* ... */ }
    fn save_size() -> usize { 64 * 1024 }
}

let storage = Box::new(InMemoryStorage::new());
let manager = SaveManager::<MySave>::new(storage);
manager.save(SaveSlot::Slot1, &my_data)?;
let loaded = manager.load(SaveSlot::Slot1)?;

Structs§

InMemoryStorage
An in-memory SaveStorage implementation backed by Vec<Option<Vec<u8>>>.
SaveManager
Manages save/load operations across multiple slots.

Enums§

SaveError
Errors that can occur during save/load operations.
SaveSlot
Identifies a save slot.

Traits§

SaveData
Game-specific save data that can be serialized, checksummed, and persisted.
SaveStorage
Platform-specific storage backend for save data.

Functions§

crc16_xmodem
CRC-16/XMODEM: polynomial 0x1021, initial value 0x0000.