Trait futures_util::compat::AsyncRead01CompatExt [−][src]
pub trait AsyncRead01CompatExt: AsyncRead01 { fn compat(self) -> Compat01As03<Self>ⓘNotable traits for Compat01As03<Fut>
impl<Fut: Future01> Future for Compat01As03<Fut> type Output = Result<Fut::Item, Fut::Error>;
where
Self: Sized, { ... } }
This is supported on crate features
compat
and io-compat
only.Expand description
Extension trait for tokio-io AsyncRead
Provided methods
fn compat(self) -> Compat01As03<Self>ⓘNotable traits for Compat01As03<Fut>
impl<Fut: Future01> Future for Compat01As03<Fut> type Output = Result<Fut::Item, Fut::Error>;
where
Self: Sized,
fn compat(self) -> Compat01As03<Self>ⓘNotable traits for Compat01As03<Fut>
impl<Fut: Future01> Future for Compat01As03<Fut> type Output = Result<Fut::Item, Fut::Error>;
where
Self: Sized,
Converts a tokio-io AsyncRead
into a futures-io 0.3
AsyncRead
.
use futures::io::AsyncReadExt; use futures_util::compat::AsyncRead01CompatExt; let input = b"Hello World!"; let reader /* : impl tokio_io::AsyncRead */ = std::io::Cursor::new(input); let mut reader /* : impl futures::io::AsyncRead + Unpin */ = reader.compat(); let mut output = Vec::with_capacity(12); reader.read_to_end(&mut output).await.unwrap(); assert_eq!(output, input);