- match std::pin::Pin::new(us.writer.as_mut().unwrap()).poll_write(&mut ctx, &data[written_len..]) {
- task::Poll::Ready(Ok(res)) => {
- // The tokio docs *seem* to indicate this can't happen, and I certainly don't
- // know how to handle it if it does (cause it should be a Poll::Pending
- // instead):
- assert_ne!(res, 0);
- written_len += res;
- if written_len == data.len() { return written_len; }
- },
- task::Poll::Ready(Err(e)) => {
- // The tokio docs *seem* to indicate this can't happen, and I certainly don't
- // know how to handle it if it does (cause it should be a Poll::Pending
- // instead):
- assert_ne!(e.kind(), io::ErrorKind::WouldBlock);
- // Probably we've already been closed, just return what we have and let the
- // read thread handle closing logic.
- return written_len;
+ match us.writer.as_ref().unwrap().poll_write_ready(&mut ctx) {
+ task::Poll::Ready(Ok(())) => {
+ match us.writer.as_ref().unwrap().try_write(&data[written_len..]) {
+ Ok(res) => {
+ debug_assert_ne!(res, 0);
+ written_len += res;
+ if written_len == data.len() { return written_len; }
+ },
+ Err(_) => return written_len,
+ }