| Crates.io | conf_watcher |
| lib.rs | conf_watcher |
| version | 0.1.3 |
| created_at | 2025-10-31 16:24:40.779771+00 |
| updated_at | 2025-11-01 21:18:39.515332+00 |
| description | A library for auto-reloading configuration files in Rust |
| homepage | |
| repository | https://github.com/rafaelxky/conf_watcher |
| max_upload_size | |
| id | 1910282 |
| size | 30,037 |
ConfWatcher allows programmers to easily watch config files (or other files) for updates or access at runtime.
Start by creating a factory Watcher.
Use it to create a WatchedFile'.
use conf_watcher::{Watcher, AutoUpdated};
fn main() {
// Create a watcher
let watcher = Watcher::new();
// Watch a file
let watched_file = watcher.watch("config.json").unwrap();
// Create an auto-updated config
let config: AutoUpdated<MyConfig> = watched_file.auto_updated().unwrap();
// Access the current config
{
let cfg = config.get();
println!("Current config: {:?}", *cfg);
}
// The watcher will automatically update `config` on file changes
}
Then you can use WatchedFile to trigger functions on update or access.
You can also create an AutoUpdated<T> variable wich will automatically update itself based on the config changes