hotreload

Crates.iohotreload
lib.rshotreload
version0.2.2
sourcesrc
created_at2024-01-16 14:15:34.057925
updated_at2024-11-10 10:05:56.408138
descriptionA simple crate to hotreload toml config files
homepage
repositoryhttps://github.com/AmionSky/hotreload
max_upload_size
id1101616
size18,162
Csányi István (AmionSky)

documentation

README

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.

Commit count: 5

cargo fmt