#toml-config #toml #data

hotreload

A simple crate to hotreload toml config files

1 unstable release

0.1.0 Jan 16, 2024

#635 in Configuration

MIT/Apache

7KB
108 lines

hotreload

A simple crate to hotreload toml config files.

Usage

#[derive(Default)]
struct Config {
    value: Mutex<i32>
}

#[derive(serde::Deserialize)]
struct Data {
    value: i32
}

impl HotreloadApply<Data> for Config {
    fn apply(&self, data: Data) {
        *self.value.lock().unwrap() = data.value;
    }
}

fn example() -> Result<(), HotreloadError> {
    let watcher = Hotreload::<Config, Data>::new("my-config.toml")?;
    let config: Arc<Config> = watcher.config().clone()
}

License

Licensed under either of

at your option.

Dependencies

~1.3–10MB
~83K SLoC