Crates.io | prefstore |
lib.rs | prefstore |
version | 0.5.0 |
source | src |
created_at | 2023-03-16 14:41:58.063416 |
updated_at | 2023-04-10 10:51:55.9364 |
description | A rust crate to Easily store and retrieve preferences in rust. |
homepage | https://github.com/visnkmr/prefstore |
repository | https://github.com/visnkmr/prefstore |
max_upload_size | |
id | 811566 |
size | 36,640 |
A rust crate to Easily store and retrieve preferences in rust.
Install the crate as a dependency in your app's Cargo.toml file:
[dependencies]
prefstore = "0.5.0"
Then you can use it in your code like this:
// Import prefstore
use prefstore::*;
fn main() {
// Save value to disk using savepreference
savepreference("MyApp", "name", "Alice");
// Save value to disk using savecustom
savecustom("MyApp", "age.txt", 25);
// Save value to disk using appendcustom
appendcustom("MyApp", "hobbies.txt", "reading");
// Load value from disk using getpreference
let name = getpreference("MyApp", "name", "Bob");
println!("Name: {}", name);
// Load value from disk using getcustom
let age = getcustom("MyApp", "age.txt", 0);
println!("Age: {}", age);
// Load value from disk using getcustomwithnodefault
let hobbies = getcustomwithnodefault("MyApp", "hobbies.txt");
println!("Hobbies: {}", hobbies);
// Delete preference file from disk using clearpreference
clearpreference("MyApp", "name");
// Delete preference file from disk using clearcustom
clearcustom("MyApp", "age.txt");
}
[Display]
for valuesThis project is licensed under the MIT license. See the LICENSE file for more details.