-
Notifications
You must be signed in to change notification settings - Fork 222
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
Add Watcher::kind() #364
Conversation
cc @jhscheer would that be an appropriate fix for you ? |
Yes, this looks very good and solves my issue. Thanks! |
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. |
There was a problem hiding this 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 👍
examples/watcher_kind/src/main.rs
Outdated
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()) | ||
}; | ||
|
||
|
||
} |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
Should both be addressed |
Closes #361