conf_watcher

Crates.ioconf_watcher
lib.rsconf_watcher
version0.1.3
created_at2025-10-31 16:24:40.779771+00
updated_at2025-11-01 21:18:39.515332+00
descriptionA library for auto-reloading configuration files in Rust
homepage
repositoryhttps://github.com/rafaelxky/conf_watcher
max_upload_size
id1910282
size30,037
Rafael Penacho (rafaelxky)

documentation

README

ConfWatcher

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

Commit count: 0

cargo fmt