Skip to main content

Crate app_json_settings

Crate app_json_settings 

Source
Expand description

Tiny typed JSON settings persistence for Rust applications.

app-json-settings stores one Serde-serializable Rust value as a JSON settings file. The crate intentionally keeps the API small: choose a storage root, optionally choose a file name, and then load, save, or update the value.

use app_json_settings::ConfigManager;

#[derive(serde::Deserialize, serde::Serialize, Default)]
struct Settings {
    volume: u32,
}

let manager = ConfigManager::<Settings>::for_app("demo-app")?;
let settings = manager.load_or_default()?;
manager.update(|settings| settings.volume = settings.volume.saturating_add(1))?;

Structs§

ConfigManager
Manages one typed JSON settings file.

Enums§

ConfigError
Error type returned by app-json-settings operations.

Constants§

DEFAULT_FILE_NAME
Default JSON settings file name.

Functions§

is_plain_file_name
Returns true when value is safe to use as a single file name.
is_safe_path_component
Returns true when value is safe to append as one path component.

Type Aliases§

Result