Expand description
This crate provides a storage agnostic way to save any serde serialize / deserialize data into save slots like you would find in a classic RPG.
It is opinionated on how the data should be stored and accessed, and expects you to be able to load an entire save slot into RAM at once.
§Example
ⓘ
use agb_save::{SaveSlotManager, StorageMedium};
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
struct SaveData {
level: u32,
health: u32,
inventory: Vec<Item>,
}
#[derive(Serialize, Deserialize)]
struct SaveMetadata {
player_name: String,
playtime_seconds: u32,
}
let mut manager = SaveSlotManager::<_, SaveMetadata>::new(
storage,
3, // 3 save slots
*b"my-game-v1.0____________________",
)?;
// Check slot status before loading
match manager.slot(0) {
Slot::Empty => println!("Slot 0 is empty"),
Slot::Valid(metadata) => {
println!("Player: {}", metadata.player_name);
}
Slot::Corrupted => println!("Slot 0 is corrupted"),
}
// Save game
manager.write(0, &save_data, &metadata)?;
// Load game
let save_data: SaveData = manager.read(0)?;Structs§
- Save
Slot Manager - A save slot manager which gives you some level of write safety and confirmation that everything worked correctly.
- Serialization
Error - Further details about the serialization error.
- Storage
Info - Data about how the
StorageMediumshould be used.
Enums§
Traits§
- Storage
Medium - Core trait for save storage access.