#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

#1542 in Encoding

Download history 31/week @ 2023-12-01 65/week @ 2023-12-08 74/week @ 2023-12-15 56/week @ 2023-12-22 22/week @ 2023-12-29 66/week @ 2024-01-05 78/week @ 2024-01-12 55/week @ 2024-01-19 46/week @ 2024-01-26 23/week @ 2024-02-02 71/week @ 2024-02-09 86/week @ 2024-02-16 84/week @ 2024-02-23 73/week @ 2024-03-01 112/week @ 2024-03-08 70/week @ 2024-03-15

349 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
~79K SLoC