I might be doing something wrong, but it genuinely suspect that the futures::Sink trait would be better off merging the poll_ready and start_send methods.
-
Show this thread
-
New method signature: fn poll_send( mut self: Pin<&mut Self>, waker: &Waker, item: Self::Item ) -> Poll<Result<(), Self::SinkError>> Current: https://docs.rs/futures-preview/0.3.0-alpha.13/futures/prelude/trait.Sink.html …
2 replies 0 retweets 1 likeShow this thread -
Replying to @yoshuawuyts
The problem is that poll_send() consumes the item and doesn't return it back when not ready. If Poll::Pending is returned by the function, it's impossible to recover the item. With poll_ready() and start_send() we pass the item only once when we're sure sending will complete.
2 replies 0 retweets 2 likes
We can also draw a parallel with channels. Sender::send() returns a SendError<T> on failure that recovers the item: https://docs.rs/crossbeam/0.7.1/crossbeam/channel/struct.Sender.html#method.send … Select::select() is like poll_ready(): https://docs.rs/crossbeam/0.7.1/crossbeam/channel/struct.Select.html#method.select … SelectedOperation::send() is like start_send(): https://docs.rs/crossbeam/0.7.1/crossbeam/channel/struct.SelectedOperation.html#method.send …
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.