Skip to content

Commit d655c66

Browse files
Merge pull request #373 from matthiasbeyer/update-notify
Update notify
2 parents eb32915 + 99bceef commit d655c66

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ reqwest = "0.11.10"
4949
serde = "1.0"
5050
glob = "0.3"
5151
lazy_static = "1"
52-
notify = "^4.0.0"
52+
notify = "^5.0.0"
5353
temp-env = "0.2.0"

examples/watch/main.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#![allow(deprecated)]
22
use config::{Config, File};
3-
use notify::{DebouncedEvent, RecommendedWatcher, RecursiveMode, Watcher};
3+
use notify::{Event, RecommendedWatcher, RecursiveMode, Watcher};
44
use std::collections::HashMap;
5+
use std::path::Path;
56
use std::sync::mpsc::channel;
67
use std::sync::RwLock;
78
use std::time::Duration;
@@ -33,19 +34,29 @@ fn watch() {
3334

3435
// Automatically select the best implementation for your platform.
3536
// You can also access each implementation directly e.g. INotifyWatcher.
36-
let mut watcher: RecommendedWatcher = Watcher::new(tx, Duration::from_secs(2)).unwrap();
37+
let mut watcher: RecommendedWatcher = Watcher::new(
38+
tx,
39+
notify::Config::default().with_poll_interval(Duration::from_secs(2)),
40+
)
41+
.unwrap();
3742

3843
// Add a path to be watched. All files and directories at that path and
3944
// below will be monitored for changes.
4045
watcher
41-
.watch("examples/watch/Settings.toml", RecursiveMode::NonRecursive)
46+
.watch(
47+
Path::new("examples/watch/Settings.toml"),
48+
RecursiveMode::NonRecursive,
49+
)
4250
.unwrap();
4351

4452
// This is a simple loop, but you may want to use more complex logic here,
4553
// for example to handle I/O.
4654
loop {
4755
match rx.recv() {
48-
Ok(DebouncedEvent::Write(_)) => {
56+
Ok(Ok(Event {
57+
kind: notify::event::EventKind::Modify(_),
58+
..
59+
})) => {
4960
println!(" * Settings.toml written; refreshing configuration ...");
5061
SETTINGS.write().unwrap().refresh().unwrap();
5162
show();

0 commit comments

Comments
 (0)