#events #notify #watch

notify-win-debouncer-full

notify-win event debouncer optimized for ease of use

1 unstable release

new 0.1.2 Dec 28, 2024

#1659 in Filesystem

Download history 119/week @ 2024-12-25

119 downloads per month

MIT/Apache

145KB
2.5K SLoC

Win Notify Debouncer Full

» Docs

A debouncer for notify-win 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 (Windows)
  • 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-win] 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 (Windows)
  • Doesn't emit duplicate create events
  • Doesn't emit Modify events after a Create event

Installation

[dependencies]
notify-win-debouncer-full = "0.1.0"

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

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

Examples

use notify_win_debouncer_full::{notify_win::*, 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

Dependencies

~9–17MB
~222K SLoC