use std::path::Path;
#[derive(Debug)]
pub(crate) struct Watcher {
_watcher: notify::RecommendedWatcher,
}
impl Watcher {
pub(crate) fn on(
dir: &Path,
handler: impl notify::EventHandler,
_ended: impl Fn() + Send + 'static,
) -> notify::Result<Watcher> {
use notify::Watcher as _;
let mut watcher = notify::RecommendedWatcher::new(handler, notify::Config::default())?;
watcher.watch(dir, notify::RecursiveMode::NonRecursive)?;
Ok(Watcher { _watcher: watcher })
}
}