Trait futures::io::AsyncRead [−][src]
pub trait AsyncRead { pub fn poll_read(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8]
) -> Poll<Result<usize, Error>>; pub fn poll_read_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &mut [IoSliceMut<'_>]
) -> Poll<Result<usize, Error>> { ... } }
Read bytes asynchronously.
This trait is analogous to the std::io::Read
trait, but integrates
with the asynchronous task system. In particular, the poll_read
method, unlike Read::read
, will automatically queue the current task
for wakeup and return if data is not yet available, rather than blocking
the calling thread.
Required methods
pub fn poll_read(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8]
) -> Poll<Result<usize, Error>>
[src][−]
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8]
) -> Poll<Result<usize, Error>>
Attempt to read from the AsyncRead
into buf
.
On success, returns Poll::Ready(Ok(num_bytes_read))
.
If no data is available for reading, the method returns
Poll::Pending
and arranges for the current task (via
cx.waker().wake_by_ref()
) to receive a notification when the object becomes
readable or is closed.
Implementation
This function may not return errors of kind WouldBlock
or
Interrupted
. Implementations must convert WouldBlock
into
Poll::Pending
and either internally retry or convert
Interrupted
into another error kind.
Provided methods
pub fn poll_read_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &mut [IoSliceMut<'_>]
) -> Poll<Result<usize, Error>>
[src][−]
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &mut [IoSliceMut<'_>]
) -> Poll<Result<usize, Error>>
Attempt to read from the AsyncRead
into bufs
using vectored
IO operations.
This method is similar to poll_read
, but allows data to be read
into multiple buffers using a single operation.
On success, returns Poll::Ready(Ok(num_bytes_read))
.
If no data is available for reading, the method returns
Poll::Pending
and arranges for the current task (via
cx.waker().wake_by_ref()
) to receive a notification when the object becomes
readable or is closed.
By default, this method delegates to using poll_read
on the first
nonempty buffer in bufs
, or an empty one if none exists. Objects which
support vectored IO should override this method.
Implementation
This function may not return errors of kind WouldBlock
or
Interrupted
. Implementations must convert WouldBlock
into
Poll::Pending
and either internally retry or convert
Interrupted
into another error kind.
Implementations on Foreign Types
impl<T> AsyncRead for Box<T, Global> where
T: AsyncRead + Unpin + ?Sized,
[src]
impl<T> AsyncRead for Box<T, Global> where
T: AsyncRead + Unpin + ?Sized,
[src]impl<'_> AsyncRead for &'_ [u8]
[src]
impl<'_> AsyncRead for &'_ [u8]
[src]impl<P> AsyncRead for Pin<P> where
P: DerefMut + Unpin,
<P as Deref>::Target: AsyncRead,
[src]
impl<P> AsyncRead for Pin<P> where
P: DerefMut + Unpin,
<P as Deref>::Target: AsyncRead,
[src]impl<'_, T> AsyncRead for &'_ mut T where
T: AsyncRead + Unpin + ?Sized,
[src]
impl<'_, T> AsyncRead for &'_ mut T where
T: AsyncRead + Unpin + ?Sized,
[src]Implementors
impl<St> AsyncRead for IntoAsyncRead<St> where
St: TryStream<Error = Error> + Unpin,
<St as TryStream>::Ok: AsRef<[u8]>,
[src]
impl<St> AsyncRead for IntoAsyncRead<St> where
St: TryStream<Error = Error> + Unpin,
<St as TryStream>::Ok: AsRef<[u8]>,
[src]impl<T> AsyncRead for AllowStdIo<T> where
T: Read,
[src]
impl<T> AsyncRead for AllowStdIo<T> where
T: Read,
[src]impl<T: Read> AsyncRead for Async<T>
impl<T: Read> AsyncRead for Async<T>
impl<T> AsyncRead for &Async<T> where
&'a T: Read,
impl<T> AsyncRead for &Async<T> where
&'a T: Read,
impl AsyncRead for ChildStdout
impl AsyncRead for ChildStdout
impl AsyncRead for ChildStderr
impl AsyncRead for ChildStderr
impl<T: Read + Send + 'static> AsyncRead for Unblock<T>
impl<T: Read + Send + 'static> AsyncRead for Unblock<T>
impl<T: Read> AsyncRead for AssertAsync<T>
impl<T: Read> AsyncRead for AssertAsync<T>
impl<R: AsyncRead> AsyncRead for BufReader<R>
impl<R: AsyncRead> AsyncRead for BufReader<R>
impl<T> AsyncRead for Cursor<T> where
T: AsRef<[u8]> + Unpin,
impl<T> AsyncRead for Cursor<T> where
T: AsRef<[u8]> + Unpin,
impl AsyncRead for Empty
impl AsyncRead for Empty
impl AsyncRead for Repeat
impl AsyncRead for Repeat
impl<R: AsyncRead> AsyncRead for Take<R>
impl<R: AsyncRead> AsyncRead for Take<R>
impl<R: AsyncRead> AsyncRead for Bytes<R>
impl<R: AsyncRead> AsyncRead for Bytes<R>
impl<R1: AsyncRead, R2: AsyncRead> AsyncRead for Chain<R1, R2>
impl<R1: AsyncRead, R2: AsyncRead> AsyncRead for Chain<R1, R2>
impl<T: AsyncRead + Unpin> AsyncRead for ReadHalf<T>
impl<T: AsyncRead + Unpin> AsyncRead for ReadHalf<T>
impl<IO> AsyncRead for TlsStream<IO> where
IO: AsyncRead + AsyncWrite + Unpin,
impl<IO> AsyncRead for TlsStream<IO> where
IO: AsyncRead + AsyncWrite + Unpin,
impl<IO> AsyncRead for TlsStream<IO> where
IO: AsyncRead + AsyncWrite + Unpin,
impl<IO> AsyncRead for TlsStream<IO> where
IO: AsyncRead + AsyncWrite + Unpin,
impl<T> AsyncRead for TlsStream<T> where
T: AsyncRead + AsyncWrite + Unpin,
impl<T> AsyncRead for TlsStream<T> where
T: AsyncRead + AsyncWrite + Unpin,
impl<TInner: AsyncRead> AsyncRead for BandwidthConnecLogging<TInner>
impl<TInner: AsyncRead> AsyncRead for BandwidthConnecLogging<TInner>
impl<A, B> AsyncRead for EitherOutput<A, B> where
A: AsyncRead,
B: AsyncRead,
impl<A, B> AsyncRead for EitherOutput<A, B> where
A: AsyncRead,
B: AsyncRead,
impl<P> AsyncRead for SubstreamRef<P> where
P: Deref,
P::Target: StreamMuxer,
impl<P> AsyncRead for SubstreamRef<P> where
P: Deref,
P::Target: StreamMuxer,
impl AsyncRead for DummyStream
impl AsyncRead for DummyStream
impl<S> AsyncRead for DeflateOutput<S> where
S: AsyncRead + Unpin,
impl<S> AsyncRead for DeflateOutput<S> where
S: AsyncRead + Unpin,
impl<T: AsyncRead + Unpin> AsyncRead for NoiseOutput<T>
impl<T: AsyncRead + Unpin> AsyncRead for NoiseOutput<T>
impl<S: AsyncRead + AsyncWrite + Unpin> AsyncRead for PlainTextOutput<S>
impl<S: AsyncRead + AsyncWrite + Unpin> AsyncRead for PlainTextOutput<S>
impl<S: AsyncRead + AsyncWrite> AsyncRead for PnetOutput<S>
impl<S: AsyncRead + AsyncWrite> AsyncRead for PnetOutput<S>
impl AsyncRead for Connection
impl AsyncRead for Connection
impl<TInner> AsyncRead for Negotiated<TInner> where
TInner: AsyncRead + AsyncWrite + Unpin,
impl<TInner> AsyncRead for Negotiated<TInner> where
TInner: AsyncRead + AsyncWrite + Unpin,
impl<S> AsyncRead for RwStreamSink<S> where
S: TryStream<Error = Error>,
<S as TryStream>::Ok: AsRef<[u8]>,
impl<S> AsyncRead for RwStreamSink<S> where
S: TryStream<Error = Error>,
<S as TryStream>::Ok: AsRef<[u8]>,
impl AsyncRead for Stream
impl AsyncRead for Stream