-
Notifications
You must be signed in to change notification settings - Fork 229
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
Make Watcher
object safe
#336
Conversation
This changes the `Watcher` trait to be object safe, which allows users to dynamically select which backend to use. This can be helpful on systems that support multiple file watching systems that have different tradeoffs. For example, Chromium's file watcher on OS X will use an fsevent backend when watching recursive directories, and a kqueues backend when not. In order to implement this, this makes a few changes to Watcher: * removes `new_immediate` constructor. * removes the `<P: AsRef<Path>>` from the `watch` and `unwatch`. This then replaces (and renames) calls with `notify::recommended_watcher()` to get similar behavior as the old constructor.
I think |
Correct, object safe traits can't have generic parameters. It's unfortunate to have to manually pass in |
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.
Note that you currently seem to have syntax errors according to CI.
Should be fixed now! |
Thanks, this will be a good step towards a possible dynamic runtime change, which was in the never released -next branch |
Note: we may want to document and test for this, so it isn't reverted later on with a trait under the impression of usability improvements |
Thanks!
I did add a simple test for this in src/lib.rs, where I assert that the |
Ah yeah, had to test but that's already enough to verify it. Then I'll only have to add some docs later on for a more in-depth changelog |
Notion of "immediate mode" was removed in notify-rs#336.
Notion of "immediate mode" was removed in notify-rs#336.
Notion of "immediate mode" was removed in #336.
This changes the
Watcher
trait to be object safe, which allows users todynamically select which backend to use. This can be helpful on systems that
support multiple file watching systems that have different tradeoffs. For
example, Chromium's file watcher on OS X will use an fsevent backend
when watching recursive directories, and a kqueues backend when not.
In order to implement this, this makes a few changes to Watcher:
new_immediate
constructor.<P: AsRef<Path>>
from thewatch
andunwatch
.This then replaces (and renames) calls with
notify::recommended_watcher()
to get similar behavior as the old constructor.