summaryrefslogtreecommitdiffstats
path: root/tokio-test
diff options
context:
space:
mode:
authorSean McArthur <sean@seanmonstar.com>2019-07-15 14:53:16 -0700
committerCarl Lerche <me@carllerche.com>2019-07-15 14:53:16 -0700
commit7f7f74985e18a6bbe6e05e49ca2407506a000889 (patch)
tree722ed3833880fb29f71fbf75a067528548feb459 /tokio-test
parente6cf976662d21974f69fa7d4d60fb27b887c6c47 (diff)
io: Minor adjustments to tokio-test IO (#1306)
This also re-exports `bytes::{Buf, BufMut}` from `tokio-io`.
Diffstat (limited to 'tokio-test')
-rw-r--r--tokio-test/src/io.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/tokio-test/src/io.rs b/tokio-test/src/io.rs
index 881ffe1a..4e4ec1b3 100644
--- a/tokio-test/src/io.rs
+++ b/tokio-test/src/io.rs
@@ -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(()))
}