Skip to content

Commit

Permalink
improve upgrade docs and fix Config link
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpr03 committed Aug 28, 2022
1 parent 65da37b commit a83279f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
20 changes: 17 additions & 3 deletions UPGRADING_V4_TO_V5.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,26 @@

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).
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 relied on `RawEvent`, this got replaced by `Event`.

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.
The old `DebouncedEvent` is completely removed. notify-debouncer-mini only reports an `Any` like event (named `DebouncedEvent` too) as relying on specific kinds (Write/Create/Remove) is very plattform specific and [can't](https://github.com/notify-rs/notify/issues/261) [be](https://github.com/notify-rs/notify/issues/187) [guaranteed](https://github.com/notify-rs/notify/issues/272) to work, relying on a lot of assumptions. In most cases you should check anway what exactly the state of files is, or probably re-run your application code, not relying on which event happened.

If you've used the previously by default debounced API, please see [here](https://github.com/notify-rs/notify/blob/main/examples/debounced.rs) for an example using the new crate.

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.
Watchers now accept the `EventHandler` trait for event handling, allowing for callbacks and foreign channels.

## Config

All watcher only expose the `Watcher` trait, which takes an `EventHandler` and a `Config`, the latter being used to possibly initialize things that can only be specified before running the watcher. One Example would be the `compare_contents` from `PollWatcher`.

## Features

Notify v5 by default uses crossbeam-channel internally. You can disable this (required for tokio) as documented in the crate, this may be required for tokio users.

For macOS the kqueue backend can now be used alternatively by using the `macos_kqueue` feature.

## Plattforms

Plattform support in v5 now includes BSD and kqueue on macos in addition to fsevent.
2 changes: 1 addition & 1 deletion notify/src/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ mod data {
/// By default scans through all files and checks for changed entries based on their change date.
/// Can also be changed to perform file content change checks.
///
/// See [PollWatcherConfig] for more details.
/// See [Config] for more details.
#[derive(Debug)]
pub struct PollWatcher {
watches: Arc<Mutex<HashMap<PathBuf, WatchData>>>,
Expand Down

0 comments on commit a83279f

Please sign in to comment.