-
Notifications
You must be signed in to change notification settings - Fork 65
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
Consider unifying traditional and future-based APIs #112
Comments
One thought on this would be that the current stream API takes &mut on the Inotify and does not provide a way to add additional watches. I'm working on something where I want to recursively watch a directory, and thus need to add new watches on any newly created directories. One solution would be to allow mutably borrowing an inotify from the stream, or adding functions to add/remove watches directly. Personally I would favor adding a method to clone an Inotify. It should be safe (in a Rust sense) and the underlying representation is already friendly to this. I understand this would permit certain undesirable uses (e.g., two streams on the same inotify would each get a subset of events). I've tried a few ways of writing this involving multiple threads, etc, which have all been clumsy. Next I want to try using |
Thank you for your feedback, @calmofthestorm. I'm very open to improving the situation and make your use case possible, but I think allowing users to clone But does creating an Maybe it would be better to replace |
Thanks, I missed that the mut reference is not saved by I like Then you have two separate concerns -- configuring the inotify, and consuming its events. The latter can be made unique to solve the two streams on the same fd problem. |
Currently there are two parallel APIs: The original one, and the new future-based one. I think it would be ideal if we could unify those.
One problem I see is efficiency. The stream-based API requires one additional heap allocation for every event that has a
name
. The reason for this are lifetime issues that probably can't be resolved, at least not in safe Rust.I think it's best for now to keep things as they are, while keeping a look at how futures develop. Feedback is very welcome!
The text was updated successfully, but these errors were encountered: