#toml-config #toml

hotreload

A simple crate to hotreload toml config files

5 unstable releases

new 0.3.0 Mar 7, 2025
0.2.2 Nov 10, 2024
0.2.1 Jun 30, 2024
0.2.0 Jun 27, 2024
0.1.0 Jan 16, 2024

#631 in Configuration

Download history 8/week @ 2024-11-17 1/week @ 2024-11-24 13/week @ 2024-12-08 5/week @ 2025-02-09 4/week @ 2025-02-16 3/week @ 2025-02-23 97/week @ 2025-03-02

109 downloads per month

MIT/Apache

10KB
85 lines

hotreload

A simple crate to hotreload toml config files.

Usage

use hotreload::{Hotreload, Apply};

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

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

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

fn example() -> Result<(), hotreload::Error> {
    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

~0.9–8.5MB
~76K SLoC