#watch #events #notify

hotwatch

A Rust library for conveniently watching and handling file changes

13 releases

0.5.0 Jun 1, 2023
0.4.6 Oct 12, 2021
0.4.5 Nov 25, 2020
0.4.3 Dec 3, 2019
0.1.0 Nov 12, 2016

#724 in Filesystem

Download history 741/week @ 2024-06-14 676/week @ 2024-06-21 327/week @ 2024-06-28 328/week @ 2024-07-05 902/week @ 2024-07-12 966/week @ 2024-07-19 765/week @ 2024-07-26 981/week @ 2024-08-02 1043/week @ 2024-08-09 1120/week @ 2024-08-16 993/week @ 2024-08-23 723/week @ 2024-08-30 948/week @ 2024-09-06 1031/week @ 2024-09-13 880/week @ 2024-09-20 675/week @ 2024-09-27

3,574 downloads per month
Used in 27 crates (26 directly)

MIT/Apache

18KB
255 lines

hotwatch

Crates.io Docs.rs CI Status

hotwatch is a Rust library for comfortably watching and handling file changes. It's a thin convenience wrapper over notify, allowing you to easily set callbacks for each path you want to watch.

Only the latest stable version of Rust is supported.

use hotwatch::{Hotwatch, Event, EventKind};

let mut hotwatch = Hotwatch::new().expect("hotwatch failed to initialize!");
hotwatch.watch("war.png", |event: Event| {
    if let EventKind::Modify(_) = event.kind {
        println!("War has changed.");
    }
}).expect("failed to watch file!");

Why should I use this instead of warmy?

warmy is a more general solution for responding to resource changes. hotwatch is very simplistic and intends to be trivial to integrate.

I've never actually used warmy, though. It's probably awesome. I just know that hotwatch is really easy to use and has a sexy name.

Dependencies

~1.1–8MB
~63K SLoC