zonfig
zonfig loads JSON, YAML, and TOML config files into Serde types, then keeps a watched config handle up to date while the process is running.
Features
- JSON, YAML, and TOML support.
- Extension-based format detection, with an explicit format override when needed.
- A cloneable
Config<T>handle that works well in HTTP application state. - Hot reload hooks for successful updates and reload errors.
- A cooldown window to avoid repeated reloads during save bursts.
Load Once
use Deserialize;
Watch And Reload
use Deserialize;
async
Config<T> is cheap to clone. Store it in application state and call with or get whenever a handler needs the current value.
For example:
Set a reload cooldown:
let config =
.await?;
Notes
- Reads use
ArcSwap, sogetreturns anArc<T>snapshot without cloning the config. - A failed reload keeps the last valid config.
- The watcher stays alive until all
Config<T>handles are dropped. - This crate intentionally focuses on local files. It does not merge multiple files, read remote config stores, or write config files back to disk.