app_json_settings/lib.rs
1//! Tiny typed JSON settings persistence for Rust applications.
2//!
3//! `app-json-settings` stores one Serde-serializable Rust value as a JSON
4//! settings file. The crate intentionally keeps the API small: choose a storage
5//! root, optionally choose a file name, and then load, save, or update the value.
6//!
7//! ```rust,no_run
8//! use app_json_settings::ConfigManager;
9//!
10//! #[derive(serde::Deserialize, serde::Serialize, Default)]
11//! struct Settings {
12//! volume: u32,
13//! }
14//!
15//! # fn main() -> app_json_settings::Result<()> {
16//! let manager = ConfigManager::<Settings>::for_app("demo-app")?;
17//! let settings = manager.load_or_default()?;
18//! manager.update(|settings| settings.volume = settings.volume.saturating_add(1))?;
19//! # let _ = settings;
20//! # Ok(())
21//! # }
22//! ```
23
24mod core;
25
26pub use core::ConfigManager;
27pub use core::constant::DEFAULT_FILE_NAME;
28pub use core::error::{ConfigError, Result};
29pub use core::validation::{is_plain_file_name, is_safe_path_component};