io: Minor adjustments to tokio-test IO (#1306)

This also re-exports `bytes::{Buf, BufMut}` from `tokio-io`.
This commit is contained in:
Sean McArthur
2019-07-15 14:53:16 -07:00
committed by Carl Lerche
parent e6cf976662
commit 7f7f74985e
2 changed files with 14 additions and 2 deletions
+11 -1
View File
@@ -21,7 +21,7 @@ use std::time::{Duration, Instant};
use std::{cmp, io};
use futures_core::ready;
use tokio_io::{AsyncRead, AsyncWrite};
use tokio_io::{AsyncRead, AsyncWrite, Buf};
use tokio_sync::mpsc;
use tokio_timer::{clock, timer, Delay};
@@ -409,6 +409,16 @@ impl AsyncWrite for Mock {
}
}
fn poll_write_buf<B: Buf>(
self: Pin<&mut Self>,
cx: &mut task::Context<'_>,
buf: &mut B,
) -> Poll<io::Result<usize>> {
let n = ready!(self.poll_write(cx, buf.bytes()))?;
buf.advance(n);
Poll::Ready(Ok(n))
}
fn poll_flush(self: Pin<&mut Self>, _cx: &mut task::Context<'_>) -> Poll<io::Result<()>> {
Poll::Ready(Ok(()))
}