#local-storage #storage-api #local-file #web #data #js #quad-storage

quad-storage-sys

Simple local storage API using Web Storage API in WASM. This only works on wasm. For a higher level API use quad-storage.

1 unstable release

0.1.0 Aug 31, 2021

#968 in WebAssembly

Download history 18/week @ 2024-03-12 25/week @ 2024-03-19 17/week @ 2024-03-26 38/week @ 2024-04-02 11/week @ 2024-04-09 14/week @ 2024-04-16 22/week @ 2024-04-23 21/week @ 2024-04-30 9/week @ 2024-05-07 21/week @ 2024-05-14 26/week @ 2024-05-21 23/week @ 2024-05-28 20/week @ 2024-06-04 21/week @ 2024-06-11 20/week @ 2024-06-18 15/week @ 2024-06-25

79 downloads per month
Used in 2 crates (via quad-storage)

MIT/Apache

5KB
59 lines

quad-storage

Docs Crates.io version

This is the crate to save data in persistent local storage in miniquad/macroquad environment. In WASM the data persists even if tab or browser are closed. To achieve that Web Storage API is used. To save data on native platforms, data is just saved to the local file named local.data.

Web demo.

Code example

let storage = &mut quad_storage::STORAGE.lock().unwrap();
storage.set("test", "value");
let value = storage.get("test").unwrap();
dbg!(value);

Usage

Add this to your Cargo.toml dependencies:

quad-storage = "0.1.0"

Usage in WASM

Add file quad-storage/js/quad-storage.js to your project.

Add file sapp-jsutils/js/sapp_jsutils.js file to your project.

Add this lines after loading of gl.js and before loading of your wasm in your index.html:

<script src="sapp_jsutils.js"></script>
<script src="quad-storage.js"></script>

Done! Now you can use this crate.


lib.rs:

Provides access to the browser's local storage.

Add file quad-storage/js/quad-storage.js to your project.

Add file sapp-jsutils/js/sapp_jsutils.js file to your project.

Add this lines after loading of gl.js and before loading of your wasm in your index.html:

<script src="sapp_jsutils.js"></script>
<script src="quad-storage.js"></script>

Done! Now you can use this crate.

Dependencies

~14KB