minimal/
main.rs

1use rusty_store::{StoreManager, Storage, Storing};
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Default, Storing)]
5pub struct MyStore {
6    pub count: u32,
7}
8
9pub trait MyStoreTrait {
10    fn increment_count(&mut self) -> Result<(), rusty_store::StoreError>;
11}
12
13impl MyStoreTrait for StoreManager<MyStore> {
14    fn increment_count(&mut self) -> Result<(), rusty_store::StoreError> {
15        self.modify_store(|store| store.count += 1)
16    }
17}
18
19fn main() {
20    // Initialize the Storage and create a new manager
21    let mut counter: StoreManager<MyStore> = Storage::new("com.github.mazynoah.storage")
22        .new_manager("manager")
23        .expect("Failed to create StoreManager");
24
25    counter
26        .increment_count()
27        .expect("Could not increment count");
28
29    println!("Count: {}", counter.get_store().count);
30}