#watch #events #notify

notify-debouncer-full

notify event debouncer optimized for ease of use

5 releases (breaking)

0.5.0 Jan 10, 2025
0.4.0 Oct 25, 2024
0.3.2 Oct 14, 2024
0.3.1 Aug 21, 2023
0.1.0 May 17, 2023

#112 in Filesystem

Download history 44915/week @ 2025-01-08 36968/week @ 2025-01-15 36514/week @ 2025-01-22 41023/week @ 2025-01-29 46656/week @ 2025-02-05 48132/week @ 2025-02-12 64486/week @ 2025-02-19 64410/week @ 2025-02-26 56187/week @ 2025-03-05 67200/week @ 2025-03-12 75454/week @ 2025-03-19 64397/week @ 2025-03-26 60373/week @ 2025-04-02 72159/week @ 2025-04-09 72075/week @ 2025-04-16 66692/week @ 2025-04-23

283,759 downloads per month
Used in 171 crates (59 directly)

MIT/Apache

240KB
4K SLoC

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.5.0"

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.5.0"
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:

  • serde passed down to notify-types, off by default
  • web-time passed down to notify-types, off by default
  • crossbeam-channel passed down to notify, off by default
  • macos_fsevent passed down to notify, off by default
  • macos_kqueue 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.


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

Dependencies

~0.2–8MB
~55K SLoC