Crates.io | hotreload |
lib.rs | hotreload |
version | 0.2.2 |
source | src |
created_at | 2024-01-16 14:15:34.057925 |
updated_at | 2024-11-10 10:05:56.408138 |
description | A simple crate to hotreload toml config files |
homepage | |
repository | https://github.com/AmionSky/hotreload |
max_upload_size | |
id | 1101616 |
size | 18,162 |
A simple crate to hotreload toml config files.
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()
}
Licensed under either of
at your option.