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

Add Watcher::kind() #364

Merged
merged 1 commit into from Sep 30, 2021
Merged

Add Watcher::kind() #364

merged 1 commit into from Sep 30, 2021

Conversation

0xpr03
Copy link
Member

@0xpr03 0xpr03 commented Sep 29, 2021

Closes #361

@0xpr03
Copy link
Member Author

0xpr03 commented Sep 29, 2021

cc @jhscheer would that be an appropriate fix for you ?

@jhscheer
Copy link
Contributor

Yes, this looks very good and solves my issue. Thanks!

@0xpr03
Copy link
Member Author

0xpr03 commented Sep 29, 2021

Note that non-boxing would require an enum that matches the CFG chaos of RecommendedWatcher, adding an enum for every possible configurable watcher combination. And otherwise we'll have to add the specific config calls to the trait.

Copy link
Member

@JohnTitor JohnTitor left a comment

Choose a reason for hiding this comment

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

Overall LGTM with a few nits 👍

Comment on lines 3 to 11
use notify::*;
fn main() {

let (tx, rx) = std::sync::mpsc::channel();
let watcher: Box<dyn Watcher> = if RecommendedWatcher::kind() == WatcherKind::PollWatcher {
Box::new(PollWatcher::with_delay(tx,Duration::from_secs(1)).unwrap())
} else {
Box::new(RecommendedWatcher::new(tx).unwrap())
};


}
Copy link
Member

Choose a reason for hiding this comment

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

It'd be great if we could remove blank lines (i.e. follow rustfmt).

@@ -185,6 +185,23 @@ impl EventHandler for std::sync::mpsc::Sender<Result<Event>> {
}
}

/// Watcher kind enumeration
#[derive(Debug,PartialEq,Eq)]
pub enum WatcherKind {
Copy link
Member

Choose a reason for hiding this comment

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

I guess we'll add/remove watchers in the future (actually, kqueue has been added recently) so it should make sense to add the #[non_exhaustive] attribute.

Note that non-boxing would require an enum that matches the CFG chaos of RecommendedWatcher, adding an enum for every possible configurable watcher combination. And otherwise we'll have to add the specific config calls to the trait.

Closes #361
@0xpr03
Copy link
Member Author

0xpr03 commented Sep 29, 2021

Should both be addressed

@0xpr03 0xpr03 merged commit db9841a into main Sep 30, 2021
@0xpr03 0xpr03 deleted the try_add_361 branch September 30, 2021 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Which Watcher do I get?
3 participants