Delegate Future implementation to Next struct #1372
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Inspired by #1368
I don't know if this is something you care to merge or not, but I've done the work to implement a more "standard" way to interact with Subscriber asynchronously
Previously, reading values out of Subscriber asynchronously would involve awaiting an
&mut Subscriber
, which causes re-polling the same future after it yields a value. This is considered 'improper' for a Future, and more closely maps to the Stream trait. Unfortunately,Stream
has not been standardized and so implementing that trait would require pulling in thefutures-core
dependency, which is not yet 1.0 and subject to change. Instead, this implements a Stream-likepoll_next
method onSubscriber
, and exposes that from an implementation of Future for a newNext<'_>
type, which can be constructed by calling.next()
on a Subscriber. This allows for a more traditional interaction with futures that mimics how other libraries produce values.Note that it is still possible to indefinitely poll on an
&mut Next<'_>
type to pull every value out of the subscriber, but it is less intuitive to perform that operation and it likely won't occur in downstream projects.