1use rusty_store::{Storage, StoreManager, Storing};
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Default)]
5pub struct MyStore {
6 pub count: u32,
7}
8
9impl Storing for MyStore {
10 fn store_type() -> rusty_store::StoringType {
11 rusty_store::StoringType::Custom("./app_data_folder/stores/".into())
12 }
13}
14
15impl MyStore {
16 fn increment_count(&mut self) {
17 self.count += 1;
18 }
19}
20
21fn main() {
22 let storage = Storage::new("com.github.mazynoah.storage");
24
25 let mut counter_manager = storage
27 .new_manager::<MyStore>("custom_location")
28 .expect("Failed to create StoreManager");
29
30 let mut counter_manager = StoreManager::<MyStore>::new(&storage, "custom_location")
32 .expect("Failed to create StoreManager");
33
34 let counter = counter_manager.get_store_mut();
36
37 counter.count = 75;
38 counter.increment_count();
39
40 counter_manager
42 .save()
43 .expect("Failed to save count to storage");
44
45 let counter = counter_manager.get_store();
46
47 println!("Count: {}", counter.count);
48}