-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
send errors in debouncer, add example, name thread
- Loading branch information
Showing
2 changed files
with
73 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use std::{path::Path, time::Duration}; | ||
|
||
use notify::{new_debouncer, RecursiveMode, Watcher}; | ||
|
||
fn main() { | ||
std::thread::spawn(|| { | ||
let path = Path::new("test.txt"); | ||
let _ = std::fs::remove_file(&path); | ||
loop { | ||
std::fs::write(&path, b"Lorem ipsum").unwrap(); | ||
std::thread::sleep(Duration::from_millis(250)); | ||
} | ||
}); | ||
|
||
let (rx, mut watcher) = new_debouncer(Duration::from_secs(2)).unwrap(); | ||
|
||
watcher | ||
.watch(Path::new("."), RecursiveMode::Recursive) | ||
.unwrap(); | ||
|
||
for events in rx { | ||
for e in events { | ||
println!("{:?}", e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters