diff --git a/CHANGELOG.md b/CHANGELOG.md index bcc0da13..d0035dfb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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** diff --git a/notify-debouncer-full/Cargo.toml b/notify-debouncer-full/Cargo.toml index 0a5a76c8..91ff54c3 100644 --- a/notify-debouncer-full/Cargo.toml +++ b/notify-debouncer-full/Cargo.toml @@ -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"] diff --git a/notify-debouncer-full/README.md b/notify-debouncer-full/README.md index d0824537..13b6845f 100644 --- a/notify-debouncer-full/README.md +++ b/notify-debouncer-full/README.md @@ -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 diff --git a/notify-debouncer-full/src/lib.rs b/notify-debouncer-full/src/lib.rs index fe2ccf9d..d4e4bd98 100644 --- a/notify-debouncer-full/src/lib.rs +++ b/notify-debouncer-full/src/lib.rs @@ -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 //! diff --git a/notify-debouncer-mini/Cargo.toml b/notify-debouncer-mini/Cargo.toml index da0ab460..2ca82c67 100644 --- a/notify-debouncer-mini/Cargo.toml +++ b/notify-debouncer-mini/Cargo.toml @@ -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"] diff --git a/notify-debouncer-mini/README.md b/notify-debouncer-mini/README.md index f7b69eb4..a5ffeb91 100644 --- a/notify-debouncer-mini/README.md +++ b/notify-debouncer-mini/README.md @@ -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 diff --git a/notify-debouncer-mini/src/lib.rs b/notify-debouncer-mini/src/lib.rs index 82fff9d9..1d76cbe9 100644 --- a/notify-debouncer-mini/src/lib.rs +++ b/notify-debouncer-mini/src/lib.rs @@ -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 //! diff --git a/notify-types/Cargo.toml b/notify-types/Cargo.toml index 8fc315a3..d7254c8b 100644 --- a/notify-types/Cargo.toml +++ b/notify-types/Cargo.toml @@ -14,6 +14,9 @@ authors = ["Daniel Faust "] edition = "2021" +[features] +serialization-compat-6 = [] + [dependencies] serde = { version = "1.0.89", features = ["derive"], optional = true } mock_instant = { version = "0.3.0", optional = true } diff --git a/notify-types/src/event.rs b/notify-types/src/event.rs index f5bd4145..13159813 100644 --- a/notify-types/src/event.rs +++ b/notify-types/src/event.rs @@ -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. /// @@ -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. @@ -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 @@ -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::*; diff --git a/notify/Cargo.toml b/notify/Cargo.toml index 47266f48..8730d7fd 100644 --- a/notify/Cargo.toml +++ b/notify/Cargo.toml @@ -57,3 +57,4 @@ timing_tests = [] manual_tests = [] macos_kqueue = ["kqueue", "mio"] macos_fsevent = ["fsevent-sys"] +serialization-compat-6 = ["notify-types/serialization-compat-6"] diff --git a/notify/src/lib.rs b/notify/src/lib.rs index 89a742e8..05a94bf6 100644 --- a/notify/src/lib.rs +++ b/notify/src/lib.rs @@ -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 //!