From 26c82450084222071464a8fd0bb3d8efde9e73f8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Aug 2022 18:30:31 +0000 Subject: Update notify requirement from ^4.0.0 to ^5.0.0 Updates the requirements on [notify](https://github.com/notify-rs/notify) to permit the latest version. - [Release notes](https://github.com/notify-rs/notify/releases) - [Changelog](https://github.com/notify-rs/notify/blob/main/CHANGELOG.md) - [Commits](https://github.com/notify-rs/notify/compare/notify-5.0.0-pre.16...notify-5.0.0) --- updated-dependencies: - dependency-name: notify dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 8e4a4cc..ea432ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,5 +49,5 @@ reqwest = "0.11.10" serde = "1.0" glob = "0.3" lazy_static = "1" -notify = "^4.0.0" +notify = "^5.0.0" temp-env = "0.2.0" -- cgit v1.2.3 From 99bceefee9e9d35bfd993bbd54295be092de2704 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 31 Aug 2022 07:52:02 +0200 Subject: Adapt example to new notify interface Signed-off-by: Matthias Beyer --- examples/watch/main.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/examples/watch/main.rs b/examples/watch/main.rs index 801ee4f..ca83572 100644 --- a/examples/watch/main.rs +++ b/examples/watch/main.rs @@ -1,7 +1,8 @@ #![allow(deprecated)] use config::{Config, File}; -use notify::{DebouncedEvent, RecommendedWatcher, RecursiveMode, Watcher}; +use notify::{Event, RecommendedWatcher, RecursiveMode, Watcher}; use std::collections::HashMap; +use std::path::Path; use std::sync::mpsc::channel; use std::sync::RwLock; use std::time::Duration; @@ -33,19 +34,29 @@ fn watch() { // Automatically select the best implementation for your platform. // You can also access each implementation directly e.g. INotifyWatcher. - let mut watcher: RecommendedWatcher = Watcher::new(tx, Duration::from_secs(2)).unwrap(); + let mut watcher: RecommendedWatcher = Watcher::new( + tx, + notify::Config::default().with_poll_interval(Duration::from_secs(2)), + ) + .unwrap(); // Add a path to be watched. All files and directories at that path and // below will be monitored for changes. watcher - .watch("examples/watch/Settings.toml", RecursiveMode::NonRecursive) + .watch( + Path::new("examples/watch/Settings.toml"), + RecursiveMode::NonRecursive, + ) .unwrap(); // This is a simple loop, but you may want to use more complex logic here, // for example to handle I/O. loop { match rx.recv() { - Ok(DebouncedEvent::Write(_)) => { + Ok(Ok(Event { + kind: notify::event::EventKind::Modify(_), + .. + })) => { println!(" * Settings.toml written; refreshing configuration ..."); SETTINGS.write().unwrap().refresh().unwrap(); show(); -- cgit v1.2.3