Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixup optional crossbeam feature selection in debouncer-mini #429

Merged
merged 1 commit into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ jobs:
run: cargo check -p notify --no-default-features --features=macos_kqueue
# -p notify required for feature selection!

- name: check notify debouncer mini features
if: matrix.version == 'stable'
run: cargo check -p notify-debouncer-mini --no-default-features
# -p required for feature selection to actually work!

- name: check build examples
if: matrix.version == 'stable'
run: cargo check --package examples --examples
Expand Down
6 changes: 4 additions & 2 deletions notify-debouncer-mini/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "notify-debouncer-mini"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
rust-version = "1.56"
description = "notify mini debouncer for events"
Expand All @@ -19,7 +19,9 @@ name = "notify_debouncer_mini"
path = "src/lib.rs"

[features]
default = ["crossbeam-channel"]
default = ["crossbeam"]
# can't use dep:crossbeam-channel and feature name crossbeam-channel below rust 1.60
crossbeam = ["crossbeam-channel","notify/crossbeam-channel"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another way would be renaming our dependency like:

[dependencies]
crossbeam = { package = "crossbeam-channel", version = "..." }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the crossbeam feature name doesn't sound that bad, so I'm fine either way :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh didn't think of renaming them, but yeah I'll rename the feature in the debouncer


[dependencies]
notify = "5.0.0-pre.16"
Expand Down
7 changes: 5 additions & 2 deletions notify-debouncer-mini/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@

[![» Docs](https://flat.badgen.net/badge/api/docs.rs/df3600)][docs]

Tiny debouncer for [notify](https://crates.io/crates/notify). Filters incoming events and emits only one event per timeframe per file.
Tiny debouncer for [notify]. Filters incoming events and emits only one event per timeframe per file.

## Features

- `crossbeam` enabled by default, for crossbeam channel support.
This may create problems used in tokio environments. See [#380](https://github.com/notify-rs/notify/issues/380).
<<<<<<< HEAD
Use someting like the following to disable it.
```toml
notify-debouncer-mini = { version = "*", default-features = false }
```
This also passes through to notify as `crossbeam-channel` feature.
- `serde` for serde support of event types, off by default

[docs]: https://docs.rs/notify-debouncer-mini
[docs]: https://docs.rs/notify-debouncer-mini
[notify]: https://crates.io/crates/notify
10 changes: 7 additions & 3 deletions notify-debouncer-mini/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
//! [dependencies]
//! notify-debouncer-mini = "0.1"
//! ```
//! In case you want to select specific features of notify,
//! specify notify as dependency explicitely in your dependencies.
//! Otherwise you can just use the re-export of notify from debouncer-mini.
//! ```toml
//! notify-debouncer-mini = "0.1"
//! notify = { version = "..", features = [".."] }
//! ```
//!
//! # Examples
//!
Expand Down Expand Up @@ -174,10 +181,8 @@ impl DebounceDataInner {
// TODO: perfect fit for drain_filter https://github.com/rust-lang/rust/issues/59618
for (k, v) in self.d.drain() {
if v.update.elapsed() >= self.timeout {
println!("normal timeout");
events_expired.push(DebouncedEvent::new(k, DebouncedEventKind::Any));
} else if v.insert.elapsed() >= self.timeout {
println!("continuous");
data_back.insert(k.clone(), v);
events_expired.push(DebouncedEvent::new(k, DebouncedEventKind::AnyContinuous));
} else {
Expand Down Expand Up @@ -205,7 +210,6 @@ impl DebounceDataInner {
for path in e.paths.into_iter() {
if let Some(v) = self.d.get_mut(&path) {
v.update = Instant::now();
println!("Exists");
} else {
self.d.insert(path, EventData::new_any());
}
Expand Down