use notify::RecommendedWatcher; use std::sync::Arc; use std::sync::Mutex; pub struct WatcherState { watcher: Option, } impl WatcherState { pub fn new() -> Self { Self { watcher: None } } pub fn set_watcher(&mut self, watcher: RecommendedWatcher) { self.watcher = Some(watcher); } pub fn clear_watcher(&mut self) { self.watcher = None; } } pub type SharedWatcherState = Arc>; pub fn new_shared_watcher_state() -> SharedWatcherState { Arc::new(Mutex::new(WatcherState::new())) }