use notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
use std::path::Path;
use std::sync::mpsc::channel;
use std::time::Duration;
pub fn wait_until_deleted(path: &Path) {
let (tx, rx) = channel();
let mut watcher = watcher(tx, Duration::from_secs(10)).unwrap();
match watcher.watch(path, RecursiveMode::Recursive) {
Ok(()) => {}
Err(_) => return,
};
loop {
match rx.recv() {
Ok(DebouncedEvent::NoticeRemove(_)) => return,
Err(_) => return,
Ok(_) => {} }
}
}