App JSON Settings
Typed application settings storage for Rust.
app-json-settings persists a Rust struct as your application configuration.
You do not manipulate JSON manually and you do not manage config file paths yourself.
The library focuses on safe, minimal, cross-platform configuration handling.
Quick start
# Cargo.toml
[dependencies]
serde = { version = "1", features = ["derive"] }
app-json-settings = "2"
use ConfigManager;
Why this library
Writing config handling code repeatedly leads to:
- fragile first-run initialization
- manual path handling per OS
- read → modify → write mistakes
- string-key based settings
This crate removes those concerns and lets the struct be the configuration.
Design goals
- Minimal API surface
- Predictable behavior
- No runtime dependencies beyond Serde
- Works for CLI, GUI, mobile, and server applications
This crate is not a general database or dynamic settings system. It is a typed persistent configuration layer.
Features
Safe configuration I/O
- Load and save settings with minimal code
load_or_default()prevents first-run crashesupdate()provides safe read-modify-write
Typed serialization
- Uses your own struct as the configuration model
- No string keys
- Compile-time refactor safety
- Serde
Serialize/Deserializesupported
JSON focused
-
JSON only (intentionally)
-
Selectable output:
- compact
- pretty
-
Suitable for mobile I/O constraints while still human-readable
Cross-platform support
The library internally resolves platform-specific config directories:
- Windows →
%APPDATA% - macOS →
~/Library/Application Support - Linux / Unix →
$XDG_CONFIG_HOMEor~/.config
No platform conditional code is required in your application.
Customization
let config = new
.with_filename
.disable_pretty_json;
Options:
- custom directory
- custom file name
- compact or pretty JSON output
Partial update
You usually do not need to manually load and save.
config.update?;
update() guarantees a safe read-modify-write cycle.
Choosing the right API
| Function | When to use |
|---|---|
load() |
Config file must already exist |
load_or_default() |
Normal application startup |
save() |
Replace entire configuration |
update() |
Modify part of the configuration safely |
Open-source, with care
This project is lovingly built and maintained by volunteers. We hope it helps streamline your work. Please understand that the project has its own direction — while we welcome feedback, it might not fit every edge case 🌱
Acknowledgements
Depends on the crates of serde, serde_json .