Expand description
A debouncer for notify that is optimized for ease of use.
- Only emits a single
Renameevent if the renameFromandToevents can be matched - Merges multiple
Renameevents - Takes
Renameevents 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
Removeevent when deleting a directory (inotify) - Doesn’t emit duplicate create events
- Doesn’t emit
Modifyevents after aCreateevent
§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:
serdepassed down to notify-types, off by defaultweb-timepassed down to notify-types, off by defaultcrossbeam-channelpassed down to notify, off by defaultflumepassed down to notify, off by defaultmacos_fseventpassed down to notify, off by defaultmacos_kqueuepassed down to notify, off by defaultserialization-compat-6passed down to notify, off by default
§Caveats
As all file events are sourced from notify, the known problems section applies here too.
Re-exports§
Structs§
- Debounced
Event - A debounced event is emitted after a short delay.
- Debouncer
- Debouncer guard, stops the debouncer on drop.
- File
IdMap - A cache to hold the file system IDs of all watched files.
- NoCache
- An implementation of the
FileIdCachetrait that doesn’t hold any data.
Traits§
- Debounce
Event Handler - The set of requirements for watcher debounce event handling functions.
- File
IdCache - The interface of a file ID cache.
Functions§
- new_
debouncer - Short function to create a new debounced watcher with the recommended debouncer and the built-in file ID cache.
- new_
debouncer_ opt - Creates a new debounced watcher with custom configuration.
Type Aliases§
- Debounce
Event Result - A result of debounced events. Comes with either a vec of events or vec of errors.
- Recommended
Cache - The recommended file ID cache implementation for the current platform