Module notify

Cross-platform filesystem notification library.


notify provides filesystem watching capabilities, detecting when files or directories are created, modified, deleted, or renamed. It uses platform-native APIs (inotify on Linux, FSEvents on macOS, ReadDirectoryChangesW on Windows).

The main entry point is recommended_watcher which creates a watcher appropriate for the current platform. Events are delivered through a channel or callback.

Examples

Watch a directory for changes:

use notify::{recommended_watcher, RecursiveMode, Watcher};
use std::sync::mpsc::channel;
use std::time::Duration;

let (tx, rx) = channel();

let mut watcher = recommended_watcher(move |res| {
    tx.send(res).unwrap();
}).unwrap();

watcher.watch(std::path::Path::new("."), RecursiveMode::Recursive).unwrap();

loop {
    match rx.recv_timeout(Duration::from_secs(1)) {
        Ok(Ok(event)) => println!("Change: {:?}", event),
        Ok(Err(e)) => println!("Watch error: {:?}", e),
        Err(_) => {} // Timeout, continue
    }
}

Modules

Enums

Traits

Functions

Type Aliases