#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

#1709 in Encoding

Download history 85/week @ 2024-07-21 78/week @ 2024-07-28 80/week @ 2024-08-04 100/week @ 2024-08-11 71/week @ 2024-08-18 84/week @ 2024-08-25 83/week @ 2024-09-01 63/week @ 2024-09-08 63/week @ 2024-09-15 102/week @ 2024-09-22 71/week @ 2024-09-29 7/week @ 2024-10-06 53/week @ 2024-10-13 49/week @ 2024-10-20 66/week @ 2024-10-27 70/week @ 2024-11-03

238 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–4.5MB
~84K SLoC