Notify
Cross-platform filesystem notification library for Rust.
(Looking for desktop notifications instead? Have a look at notify-rust or alert-after!)
- API Documentation
- Crate page
- Earliest supported Rust version: 1.31.1
As used by: alacritty, cargo watch, cobalt, docket, handlebars-iron, mdBook, pax, rdiff, timetrack, watchexec, xi-editor, and others.
Installation
[]
= "4.0.18"
Usage
extern crate notify;
use ;
use channel;
use Duration;
Looking overly verbose? Too much boilerplate? Have a look at hotwatch, a friendly wrapper:
// Taken from the hotwatch readme
use ;
let mut hotwatch = new.expect;
hotwatch.watch.expect;
Platforms
- Linux / Android: inotify
- macOS: FSEvents
- Windows: ReadDirectoryChangesW
- All platforms: polling
FSEvents
Due to the inner security model of FSEvents (see FileSystemEventSecurity), some event cannot be observed easily when trying to follow files that do not belong to you. In this case, reverting to the pollwatcher can fix the issue, with a slight performance cost.
Origins
Inspired by Go's fsnotify and Node.js's Chokidar, born out of need for cargo watch, and general frustration at the non-existence of C/Rust cross-platform notify libraries.
Written by Félix Saparelli and awesome contributors, and released in the Public Domain using the Creative Commons Zero Declaration.