6 releases

Uses new Rust 2021

0.2.1 Sep 4, 2022
0.2.0 Aug 30, 2022
0.1.3 Aug 17, 2022

#150 in Filesystem

Download history 35/week @ 2022-08-09 67/week @ 2022-08-16 23/week @ 2022-08-23 459/week @ 2022-08-30 712/week @ 2022-09-06 1326/week @ 2022-09-13 558/week @ 2022-09-20

3,056 downloads per month
Used in 4 crates

CC0-1.0 OR Artistic-2.0

175KB
3K SLoC

Notify debouncer

» Docs

Tiny debouncer for notify. Filters incoming events and emits only one event per timeframe per file.

Features

  • crossbeam enabled by default, for crossbeam channel support.
    This may create problems used in tokio environments. See #380.
    Use someting like the following to disable it.
notify-debouncer-mini = { version = "*", default-features = false }

This also passes through to notify as crossbeam-channel feature.

  • serde for serde support of event types, off by default

lib.rs:

Debouncer for notify

Installation

[dependencies]
notify-debouncer-mini = "0.2.0"

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

notify-debouncer-mini = "0.2.0"
notify = { version = "..", features = [".."] }

Examples

# use std::path::Path;
# use std::time::Duration;
use notify_debouncer_mini::{notify::*,new_debouncer,DebounceEventResult};

# fn main() {
    // setup initial watcher backend config
    let config = Config::default();

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

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

Features

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

  • crossbeam enabled by default, adds DebounceEventHandler support for crossbeam channels. Also enables crossbeam-channel in the re-exported notify. You may want to disable this when using the tokio async runtime.
  • serde enables serde support for events.

Dependencies

~0.4–5.5MB
~89K SLoC