Skip to content

Commit

Permalink
Add serialization-compat-6 feature
Browse files Browse the repository at this point in the history
  • Loading branch information
dfaust authored and 0xpr03 committed Mar 31, 2024
1 parent 2e1913d commit 8da5139
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ v5 maintenance branch is on `v5_maintenance` after `5.2.0`

v4 commits split out to branch `v4_maintenance` starting with `4.0.16`

## notify-types 1.0.0

New crate containing public type definitions for the notify and debouncer crates.

- CHANGE: the serialization format for events has been changed to be easier to use in environments like JavaScript;
the old behavior can be restored using the new feature flag `serialization-compat-6`

## debouncer-full 0.4.0

- CHANGE: Manage root folder paths for the file ID cache automatically. **breaking**
Expand Down
1 change: 1 addition & 0 deletions notify-debouncer-full/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ serde = ["notify-types/serde"]
mock_instant = ["dep:mock_instant","notify-types/mock_instant"]
# can't use dep:crossbeam-channel and feature name crossbeam-channel below rust 1.60
crossbeam = ["crossbeam-channel","notify/crossbeam-channel"]
serialization-compat-6 = ["notify/serialization-compat-6"]
macos_fsevent = ["notify/macos_fsevent"]
macos_kqueue = ["notify/macos_kqueue"]

Expand Down
2 changes: 2 additions & 0 deletions notify-debouncer-full/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,7 @@ A debouncer for [notify] that is optimized for ease of use.
notify-debouncer-full = { version = "*", default-features = false, features = ["macos_kqueue"] }
```

- `serialization-compat-6` passed down to notify, off by default

[docs]: https://docs.rs/notify-debouncer-full
[notify]: https://crates.io/crates/notify
1 change: 1 addition & 0 deletions notify-debouncer-full/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
//! - `crossbeam` enabled by default, adds [`DebounceEventHandler`](DebounceEventHandler) support for crossbeam channels.
//! Also enables crossbeam-channel in the re-exported notify. You may want to disable this when using the tokio async runtime.
//! - `serde` enables serde support for events.
//! - `serialization-compat-6` passed down to notify, off by default
//!
//! # Caveats
//!
Expand Down
1 change: 1 addition & 0 deletions notify-debouncer-mini/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ default = ["crossbeam","macos_fsevent"]
serde = ["notify-types/serde"]
# can't use dep:crossbeam-channel and feature name crossbeam-channel below rust 1.60
crossbeam = ["crossbeam-channel","notify/crossbeam-channel"]
serialization-compat-6 = ["notify/serialization-compat-6"]
macos_fsevent = ["notify/macos_fsevent"]
macos_kqueue = ["notify/macos_kqueue"]

Expand Down
2 changes: 2 additions & 0 deletions notify-debouncer-mini/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ Tiny debouncer for [notify]. Filters incoming events and emits only one event pe
```
- `serde` for serde support of event types, off by default

- `serialization-compat-6` passed down to notify, off by default

[docs]: https://docs.rs/notify-debouncer-mini
[notify]: https://crates.io/crates/notify
1 change: 1 addition & 0 deletions notify-debouncer-mini/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
//! - `crossbeam` enabled by default, adds [`DebounceEventHandler`](DebounceEventHandler) support for crossbeam channels.
//! Also enables crossbeam-channel in the re-exported notify. You may want to disable this when using the tokio async runtime.
//! - `serde` enables serde support for events.
//! - `serialization-compat-6` passed down to notify, off by default
//!
//! # Caveats
//!
Expand Down
3 changes: 3 additions & 0 deletions notify-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ authors = ["Daniel Faust <hessijames@gmail.com>"]

edition = "2021"

[features]
serialization-compat-6 = []

[dependencies]
serde = { version = "1.0.89", features = ["derive"], optional = true }
mock_instant = { version = "0.3.0", optional = true }
Expand Down
8 changes: 4 additions & 4 deletions notify-types/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ pub enum RemoveKind {
#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "kebab-case"))]
#[cfg_attr(feature = "serde", serde(tag = "type"))]
#[cfg_attr(all(feature = "serde", not(feature = "serialization-compat-6")), serde(tag = "type"))]
pub enum EventKind {
/// The catch-all event kind, for unsupported/unknown events.
///
Expand Down Expand Up @@ -300,7 +300,7 @@ pub struct Event {
/// The `EventKind::Any` variant should be used as the "else" case when mapping native kernel
/// bitmasks or bitmaps, such that if the mask is ever extended with new event types the
/// backend will not gain bugs due to not matching new unknown event types.
#[cfg_attr(feature = "serde", serde(flatten))]
#[cfg_attr(all(feature = "serde", not(feature = "serialization-compat-6")), serde(flatten))]
pub kind: EventKind,

/// Paths the event is about, if known.
Expand Down Expand Up @@ -478,7 +478,7 @@ impl EventAttributes {
/// particular ways.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(all(feature = "serde", not(feature = "serialization-compat-6")), serde(rename_all = "camelCase"))]
pub enum Flag {
/// Rescan notices are emitted by some platforms (and may also be emitted by Notify itself).
/// They indicate either a lapse in the events or a change in the filesystem such that events
Expand Down Expand Up @@ -618,7 +618,7 @@ impl Hash for Event {
}
}

#[cfg(all(test, feature = "serde"))]
#[cfg(all(test, feature = "serde", not(feature = "serialization-compat-6")))]
mod tests {
use super::*;

Expand Down
1 change: 1 addition & 0 deletions notify/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ timing_tests = []
manual_tests = []
macos_kqueue = ["kqueue", "mio"]
macos_fsevent = ["fsevent-sys"]
serialization-compat-6 = ["notify-types/serialization-compat-6"]
1 change: 1 addition & 0 deletions notify/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
//! - `macos_fsevent` enabled by default, for fsevent backend on macos
//! - `macos_kqueue` for kqueue backend on macos
//! - `crossbeam-channel` enabled by default, see below
//! - `serialization-compat-6` restores the serialization behavior of notify 6, off by default
//!
//! ### Serde
//!
Expand Down

0 comments on commit 8da5139

Please sign in to comment.