mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-07 00:00:08 +02:00
io: Minor adjustments to tokio-test IO (#1306)
This also re-exports `bytes::{Buf, BufMut}` from `tokio-io`.
This commit is contained in:
committed by
Carl Lerche
parent
e6cf976662
commit
7f7f74985e
+11
-1
@@ -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(()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user