agb_save 0.23.1

Library for managing saves. Designed for use with the agb library for the Game Boy Advance.
Documentation
  • Coverage
  • 100%
    33 out of 33 items documented0 out of 19 items with examples
  • Size
  • Source code size: 177.17 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.36 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 26s Average build duration of successful builds.
  • all releases: 26s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • agbrs/agb
    449 47 5
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • corwinkuiper

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)?;