#events #notify #file-rename #notifications #file-watcher #watch

notify-debouncer-full

notify event debouncer optimized for ease of use

4 releases (breaking)

0.4.0 Oct 25, 2024
0.3.2 Oct 14, 2024
0.3.1 Aug 21, 2023
0.2.0 Jun 15, 2023
0.1.0 May 17, 2023

#102 in Filesystem

Download history 41268/week @ 2024-07-28 39882/week @ 2024-08-04 35477/week @ 2024-08-11 36300/week @ 2024-08-18 39520/week @ 2024-08-25 37015/week @ 2024-09-01 35065/week @ 2024-09-08 35319/week @ 2024-09-15 41565/week @ 2024-09-22 36466/week @ 2024-09-29 41752/week @ 2024-10-06 42244/week @ 2024-10-13 45991/week @ 2024-10-20 35785/week @ 2024-10-27 45801/week @ 2024-11-03 49361/week @ 2024-11-10

179,425 downloads per month
Used in 125 crates (42 directly)

MIT/Apache

235KB
4K SLoC

Notify Debouncer Full

» Docs

A debouncer for notify that is optimized for ease of use.

  • Only emits a single Rename event if the rename From and To events can be matched
  • Merges multiple Rename events
  • Takes Rename events into account and updates paths for events that occurred before the rename event, but which haven't been emitted, yet
  • Optionally keeps track of the file system IDs all files and stitches rename events together (FSevents, Windows)
  • Emits only one Remove event when deleting a directory (inotify)
  • Doesn't emit duplicate create events
  • Doesn't emit Modify events after a Create event

Features

  • crossbeam-channel passed down to notify, off by default

  • serialization-compat-6 passed down to notify, off by default


lib.rs:

A debouncer for [notify] that is optimized for ease of use.

  • Only emits a single Rename event if the rename From and To events can be matched
  • Merges multiple Rename events
  • Takes Rename events into account and updates paths for events that occurred before the rename event, but which haven't been emitted, yet
  • Optionally keeps track of the file system IDs all files and stitches rename events together (macOS FS Events, Windows)
  • Emits only one Remove event when deleting a directory (inotify)
  • Doesn't emit duplicate create events
  • Doesn't emit Modify events after a Create event

Installation

[dependencies]
notify-debouncer-full = "0.3.1"

In case you want to select specific features of notify, specify notify as dependency explicitly in your dependencies. Otherwise you can just use the re-export of notify from debouncer-full.

notify-debouncer-full = "0.3.1"
notify = { version = "..", features = [".."] }

Examples

use notify_debouncer_full::{notify::*, new_debouncer, DebounceEventResult};

// Select recommended watcher for debouncer.
// Using a callback here, could also be a channel.
let mut debouncer = new_debouncer(Duration::from_secs(2), None, |result: DebounceEventResult| {
    match result {
        Ok(events) => events.iter().for_each(|event| println!("{event:?}")),
        Err(errors) => errors.iter().for_each(|error| println!("{error:?}")),
    }
}).unwrap();

// Add a path to be watched. All files and directories at that path and
// below will be monitored for changes.
debouncer.watch(".", RecursiveMode::Recursive).unwrap();

Features

The following crate features can be turned on or off in your cargo dependency config:

  • crossbeam-channel passed down to notify, off by default
  • serialization-compat-6 passed down to notify, off by default

Caveats

As all file events are sourced from notify, the known problems section applies here too.

Dependencies

~0.2–7MB
~49K SLoC