Crate notify_debouncer_mini
source · [−]Expand description
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 notify_debouncer_mini::{notify::*,new_debouncer,DebounceEventResult};
// 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, addsDebounceEventHandler
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.
Re-exports
pub use notify;
Structs
A debounced event.
Debouncer guard, stops the debouncer on drop
Enums
A debounced event kind.
Traits
The set of requirements for watcher debounce event handling functions.
Functions
Short function to create a new debounced watcher with the recommended debouncer.
Creates a new debounced watcher with custom configuration.
Type Definitions
A result of debounced events. Comes with either a vec of events or vec of errors.