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

Which Watcher do I get? #361

Closed
jhscheer opened this issue Sep 29, 2021 · 2 comments · Fixed by #364
Closed

Which Watcher do I get? #361

jhscheer opened this issue Sep 29, 2021 · 2 comments · Fixed by #364

Comments

@jhscheer
Copy link
Contributor

I would like to know which Watcher RecommendedWatcher::new() returns.

For example if let mut watcher = RecommendedWatcher::new(tx)?; returns a PollWatcher I would like to set the delay manually (the default is 30 seconds and cannot be adjusted later).

Maybe something like,

  1. either add an Option<Duration> parameter to Watcher::new() which will be relevant only if type RecommendedWatcher = PollWatcher; Then I could call let mut watcher = RecommendedWatcher::new(tx, Some(Duration::from_secs(1)))?;
  2. or add a whoami() method to the Watcher trait and implement setting the delay with configure(). Then I could call, e.g.
let mut watcher = RecommendedWatcher::new(tx)?;
if watcher.whoami == WatcherType::PollWatcher {
    watcher.configure(Config::SetDelay(Duration::from_secs(1)))?;
}
@0xpr03
Copy link
Member

0xpr03 commented Sep 29, 2021

The idea isn't bad, we'll need to add an enum for each type that is part of the trait, you can do a PR if you want.
FYI: You should only get the pollwatcher on anything that's not *BSD,nix,Windows,MacOS.

@0xpr03
Copy link
Member

0xpr03 commented Sep 29, 2021

I may have an implementation that sidesteps adding the params for PollWatcher to the trait.

0xpr03 added a commit that referenced this issue Sep 29, 2021
0xpr03 added a commit that referenced this issue Sep 29, 2021
0xpr03 added a commit that referenced this issue 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.

Closes #361
0xpr03 added a commit that referenced this issue 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.

Closes #361
0xpr03 added a commit that referenced this issue Sep 30, 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.

Closes #361
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants