-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rework docs and example documentation
- Loading branch information
Showing
16 changed files
with
141 additions
and
177 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
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,13 @@ | ||
# Upgrading from notify v4 to v5 | ||
|
||
This guide documents changes between v4 and v5 for upgrading existing code. | ||
|
||
Notify v5 only contains precise events. Debouncing is done by a separate crate [notify-debouncer-mini](https://github.com/notify-rs/notify/tree/main/notify-debouncer-mini). | ||
|
||
If you've used the default debounced API, please see [here](https://github.com/notify-rs/notify/blob/main/examples/debounced.rs) for an example. | ||
|
||
For precise events you can see [here](https://github.com/notify-rs/notify/blob/main/examples/monitor_raw.rs). | ||
|
||
Notify v5 by default uses crossbeam-channel internally. You can disable this (required for tokio) as documented in the crate. | ||
|
||
Plattform support in v5 now includes BSD and kqueue on macos in addition to fsevent. |
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
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
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
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
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
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
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 |
---|---|---|
@@ -1,16 +1,27 @@ | ||
use std::time::Duration; | ||
use std::{path::Path, time::Duration}; | ||
|
||
use notify::{poll::PollWatcherConfig, *}; | ||
fn main() { | ||
let (tx, _rx) = std::sync::mpsc::channel(); | ||
let _watcher: Box<dyn Watcher> = if RecommendedWatcher::kind() == WatcherKind::PollWatcher { | ||
let (tx, rx) = std::sync::mpsc::channel(); | ||
let mut watcher: Box<dyn Watcher> = if RecommendedWatcher::kind() == WatcherKind::PollWatcher { | ||
// custom config for PollWatcher kind | ||
let config = PollWatcherConfig { | ||
poll_interval: Duration::from_secs(1), | ||
..Default::default() | ||
}; | ||
Box::new(PollWatcher::with_config(tx, config).unwrap()) | ||
} else { | ||
// use default config for everything else | ||
Box::new(RecommendedWatcher::new(tx).unwrap()) | ||
}; | ||
// use _watcher here | ||
|
||
// watch some stuff | ||
watcher | ||
.watch(Path::new("."), RecursiveMode::Recursive) | ||
.unwrap(); | ||
|
||
// just print all events, this blocks forever | ||
for e in rx { | ||
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
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
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
Oops, something went wrong.