#save #save-load #desktop #location #configuration #web #cross-platform

gestalt

Cross-platform configuration and data saving between desktop and web

1 unstable release

0.1.0 Oct 20, 2019

#1619 in Encoding

Download history 84/week @ 2024-04-08 111/week @ 2024-04-15 103/week @ 2024-04-22 94/week @ 2024-04-29 88/week @ 2024-05-06 90/week @ 2024-05-13 85/week @ 2024-05-20 85/week @ 2024-05-27 76/week @ 2024-06-03 50/week @ 2024-06-10 91/week @ 2024-06-17 88/week @ 2024-06-24 34/week @ 2024-07-08 97/week @ 2024-07-15 93/week @ 2024-07-22

235 downloads per month
Used in 3 crates (via quicksilver)

MIT/Apache

16KB
260 lines

gestalt

Cross-platform configuration and data saving between desktop and web

On desktop, saving is backed by filesystem and APIs and uses the platform-specific data locations. On web, saving is backed by the LocalStorage browser API. As an end user, all you need to worry about is which Location you want to save to:

  • Cache, which is short-lived and may not persist between runs of the program
  • Config, for storing long-term configuration
  • Data, for storing long-term large data blobs.

To save and load some data:

use gestalt::{Location, save, load};
use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize)]
struct Player {
name: String,
score: u32
}

let player1 = Player { name: "Bob".to_string(), score: 21 };
save(Location::Cache, "mygame", "player1", &player1).expect("Could not save Player 1");

let player2 = Player { name: "Alice".to_string(), score: 200 };
save(Location::Cache, "mygame", "player2", &player2).expect("Could not save Player 2");

// Now reload.
let player1 = load::<Player>(Location::Cache, "mygame", "player1").expect("Could not load Player 1");
let player2 = load::<Player>(Location::Cache, "mygame", "player2").expect("Could not load Player 2");

Dependencies

~0.7–4MB
~81K SLoC