A modular configuration framework with live reloading, atomic updates, and format-agnostic loading.
live provides a complete solution for managing application configuration in Rust. It integrates atomic storage, flexible loaders, and filesystem monitoring into a unified controller, enabling applications to react to configuration changes in real-time without restarts.
- Atomic Storage: Thread-safe configuration store (
Store) using RCU semantics for wait-free reads and consistent updates. - Live Reloading: Built-in filesystem monitoring (
Watcher) that automatically detects changes and triggers reloads. - Format Agnostic: Support for multiple formats (
JSON,TOML,YAML,Postcard) with automatic detection and extension. - Secure Loading:
FileSourcewith sandbox protection against path traversal attacks. - Unified Controller: The
Live<T>controller ties everything together, providing a simple API for loading, accessing, and watching configurations. Controllers are thread-safe and cloneable, sharing resources efficiently. - Directory Scanning: The
LiveDir<T>controller manages multiple configurations from a directory, with pattern-based key extraction (e.g.,[443]→"443") and support for compound extensions (e.g.,.config.json). - Lifecycle Management:
- Validation: Integration with
validatorto ensure config validity before update. - Preprocessing: Hooks for data normalization or context injection.
- Debouncing: Intelligent event coalescing to prevent redundant reloads.
- Safe Cleanup: Automatic and shared resource management; watchers are only stopped when the last controller instance is dropped.
- Validation: Integration with
Check the examples directory for runnable code:
- Basic Usage:
examples/basic.rs- Demonstrates how to setup aLivecontroller, load a configuration, and watch for file changes. - Directory Scanning:
examples/live_dir.rs- DemonstratesLiveDirfor managing multiple configurations from a directory with pattern-based key extraction.
[dependencies]
live = { version = "0.3", features = ["full"] }| Feature | Description |
|---|---|
holder |
Enables the atomic storage module (re-exports atomhold). |
loader |
Enables the configuration loading module (re-exports fmtstruct). |
signal |
Enables the filesystem monitoring module (re-exports fsig). |
controller |
Enables the Live and LiveDir controllers (requires holder + loader + fs). |
events |
Enables event broadcasting for Store. |
fs |
Enables FileSource for loading from filesystem. |
json |
Enables JSON format support. |
toml |
Enables TOML format support. |
yaml |
Enables YAML format support. |
postcard |
Enables Postcard (binary) format support. |
validate |
Enables validator integration. |
regex |
Enables regex validation (requires validate). |
match |
Enables glob pattern matching for Watcher. |
stream |
Enables Stream API for Watcher. |
full |
Enables all features above. |
Released under the MIT License © 2026 Canmi