You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inotify::event_stream enabled concurrent use of one Inotify instance and an arbitrary number of EventStream instances, which is error-prone. It should be replaced with an into_event_stream method that consumes the Inotify. Ideally, there should also be a matching method on EventStream, to convert back to Inotify.
The proposed solution makes sense to me. Between into_event_stream() versus passing a &mut Inotify to EventStream, the into option makes it clearer what the EventStream struct's API is, and relieves the caller of having to juggle two references (Inotify and EventStream). New APIs can be duplicated on both Inotify and EventStream if they both need access, like .watches().
Originally though, my thought was "why can't inotify-rs handle multiple EventStreams, like a PubSub pattern?" But I found there's not a drop-in solution for that. People have attempted such "forking" combinators for Rust futures, but there's not a stable, wide-consensus implementation yet (see Rust futures streams GitHub issues). The Tokio streams tutorial even delegates to Redis for PubSub functionality.
So in conclusion, Inotify.into_event_stream() seems the right solution and in line with what the Rust ecosystem currently provides. Downstream projects could implement their own multi-consumer solutions on top of the EventStream if needed.
Inotify::event_stream
enabled concurrent use of oneInotify
instance and an arbitrary number ofEventStream
instances, which is error-prone. It should be replaced with aninto_event_stream
method that consumes theInotify
. Ideally, there should also be a matching method onEventStream
, to convert back toInotify
.See #112 (comment) and #112 (comment).
The text was updated successfully, but these errors were encountered: