Skip to main content

recommended_watcher

Function recommended_watcher 

Source
pub fn recommended_watcher<F>(event_handler: F) -> Result<RecommendedWatcher>
where F: EventHandler,
Expand description

Convenience method for creating the RecommendedWatcher for the current platform.

This is often the most ergonomic way to construct a watcher, because calling Watcher::new(...) requires specifying the concrete watcher type.

use notify::{Result, WatchMode, Watcher};
use std::path::Path;

fn main() -> Result<()> {
    let mut watcher = notify::recommended_watcher(|res| println!("event: {res:?}"))?;
    watcher.watch(Path::new("."), WatchMode::recursive())?;
    Ok(())
}