1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! # Rusty Store
//!
//! RustyStore is a Rust library for managing and storing serialized data using RON (Rusty Object Notation).
//!
//! ## Overview
//!
//! The library offers a set of utilities for reading, writing, and managing serialized data with RON. The primary components are:
//!
//! - `Store`: A store is any struct which implements the Storing trait.
//! - `Storage`: Manages file system paths for cache, data, and configuration storage.
//! - `StoreHandle`: Represents a handle to a specific store, allowing access and modification of the data.
//! - `StoreManager`: Provides an abstraction for managing and modifying store data, including options for committing or deferring changes.
//!
//! ## Examples
//!
//! ### `examples/minimal`
//!
//! ```rust
//! use rusty_store::{StoreManager, Storage, Storing};
//! use serde::{Deserialize, Serialize};
//!
//! #[derive(Serialize, Deserialize, Default, Storing)]
//! pub struct MyStore {
//! pub count: u32,
//! }
//!
//! pub trait MyStoreTrait {
//! fn increment_count(&mut self) -> Result<(), rusty_store::StoreError>;
//! }
//!
//! impl MyStoreTrait for StoreManager<MyStore> {
//! fn increment_count(&mut self) -> Result<(), rusty_store::StoreError> {
//! self.modify_store(|store| store.count += 1)
//! }
//! }
//!
//!
//! // Initialize the Storage and create a new manager
//! let mut counter: StoreManager<MyStore> = Storage::new("com.github.mazynoah.storage")
//! .new_manager("manager")
//! .expect("Failed to create StoreManager");
//!
//! counter
//! .increment_count()
//! .expect("Could not increment count");
//!
//! println!("Count: {}", counter.get_store().count);
//!
//! ```
//!
//! ## Traits
//!
//! - **`Storing`**: This trait must be implemented by any type that needs to be stored. It requires the type to be serializable and deserializable using RON, and provides a method to define the type of storage (`Cache`, `Data`, `Config`).
//!
extern crate rustystore_macros;
pub use Storing;
pub use StoreManager;
pub use *;