[−][src]Trait futures::io::AsyncRead
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
fn poll_read(
&mut self,
lw: &LocalWaker,
buf: &mut [u8]
) -> Poll<Result<usize, Error>>
&mut self,
lw: &LocalWaker,
buf: &mut [u8]
) -> Poll<Result<usize, Error>>
Attempt to read from the AsyncRead
into buf
.
On success, returns Ok(Async::Ready(num_bytes_read))
.
If no data is available for reading, the method returns
Ok(Async::Pending)
and arranges for the current task (via
lw.waker()
) 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
Async::Pending
and either internally retry or convert
Interrupted
into another error kind.
Provided Methods
unsafe fn initializer(&self) -> Initializer
Determines if this AsyncRead
er can work with buffers of
uninitialized memory.
The default implementation returns an initializer which will zero buffers.
Safety
This method is unsafe
because and AsyncRead
er could otherwise
return a non-zeroing Initializer
from another AsyncRead
type
without an unsafe
block.
fn poll_vectored_read(
&mut self,
lw: &LocalWaker,
vec: &mut [&mut IoVec]
) -> Poll<Result<usize, Error>>
&mut self,
lw: &LocalWaker,
vec: &mut [&mut IoVec]
) -> Poll<Result<usize, Error>>
Attempt to read from the AsyncRead
into vec
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 Ok(Async::Ready(num_bytes_read))
.
If no data is available for reading, the method returns
Ok(Async::Pending)
and arranges for the current task (via
lw.waker()
) to receive a notification when the object becomes
readable or is closed.
By default, this method delegates to using poll_read
on the first
buffer in vec
. 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
Async::Pending
and either internally retry or convert
Interrupted
into another error kind.
Implementations on Foreign Types
impl<T> AsyncRead for Box<T> where
T: AsyncRead + ?Sized,
[src]
impl<T> AsyncRead for Box<T> where
T: AsyncRead + ?Sized,
unsafe fn initializer(&self) -> Initializer
[src]
unsafe fn initializer(&self) -> Initializer
fn poll_read(
&mut self,
lw: &LocalWaker,
buf: &mut [u8]
) -> Poll<Result<usize, Error>>
[src]
fn poll_read(
&mut self,
lw: &LocalWaker,
buf: &mut [u8]
) -> Poll<Result<usize, Error>>
fn poll_vectored_read(
&mut self,
lw: &LocalWaker,
vec: &mut [&mut IoVec]
) -> Poll<Result<usize, Error>>
[src]
fn poll_vectored_read(
&mut self,
lw: &LocalWaker,
vec: &mut [&mut IoVec]
) -> Poll<Result<usize, Error>>
impl<'a> AsyncRead for &'a [u8]
[src]
impl<'a> AsyncRead for &'a [u8]
unsafe fn initializer(&self) -> Initializer
[src]
unsafe fn initializer(&self) -> Initializer
fn poll_read(
&mut self,
&LocalWaker,
buf: &mut [u8]
) -> Poll<Result<usize, Error>>
[src]
fn poll_read(
&mut self,
&LocalWaker,
buf: &mut [u8]
) -> Poll<Result<usize, Error>>
fn poll_vectored_read(
&mut self,
lw: &LocalWaker,
vec: &mut [&mut IoVec]
) -> Poll<Result<usize, Error>>
[src]
fn poll_vectored_read(
&mut self,
lw: &LocalWaker,
vec: &mut [&mut IoVec]
) -> Poll<Result<usize, Error>>
impl<T> AsyncRead for Cursor<T> where
T: AsRef<[u8]>,
[src]
impl<T> AsyncRead for Cursor<T> where
T: AsRef<[u8]>,
unsafe fn initializer(&self) -> Initializer
[src]
unsafe fn initializer(&self) -> Initializer
fn poll_read(
&mut self,
&LocalWaker,
buf: &mut [u8]
) -> Poll<Result<usize, Error>>
[src]
fn poll_read(
&mut self,
&LocalWaker,
buf: &mut [u8]
) -> Poll<Result<usize, Error>>
fn poll_vectored_read(
&mut self,
lw: &LocalWaker,
vec: &mut [&mut IoVec]
) -> Poll<Result<usize, Error>>
[src]
fn poll_vectored_read(
&mut self,
lw: &LocalWaker,
vec: &mut [&mut IoVec]
) -> Poll<Result<usize, Error>>
impl AsyncRead for Repeat
[src]
impl AsyncRead for Repeat
unsafe fn initializer(&self) -> Initializer
[src]
unsafe fn initializer(&self) -> Initializer
fn poll_read(
&mut self,
&LocalWaker,
buf: &mut [u8]
) -> Poll<Result<usize, Error>>
[src]
fn poll_read(
&mut self,
&LocalWaker,
buf: &mut [u8]
) -> Poll<Result<usize, Error>>
fn poll_vectored_read(
&mut self,
lw: &LocalWaker,
vec: &mut [&mut IoVec]
) -> Poll<Result<usize, Error>>
[src]
fn poll_vectored_read(
&mut self,
lw: &LocalWaker,
vec: &mut [&mut IoVec]
) -> Poll<Result<usize, Error>>
impl<'a, T> AsyncRead for &'a mut T where
T: AsyncRead + ?Sized,
[src]
impl<'a, T> AsyncRead for &'a mut T where
T: AsyncRead + ?Sized,
unsafe fn initializer(&self) -> Initializer
[src]
unsafe fn initializer(&self) -> Initializer
fn poll_read(
&mut self,
lw: &LocalWaker,
buf: &mut [u8]
) -> Poll<Result<usize, Error>>
[src]
fn poll_read(
&mut self,
lw: &LocalWaker,
buf: &mut [u8]
) -> Poll<Result<usize, Error>>
fn poll_vectored_read(
&mut self,
lw: &LocalWaker,
vec: &mut [&mut IoVec]
) -> Poll<Result<usize, Error>>
[src]
fn poll_vectored_read(
&mut self,
lw: &LocalWaker,
vec: &mut [&mut IoVec]
) -> Poll<Result<usize, Error>>
Implementors
impl<R> AsyncRead for Compat01As03<R> where
R: AsyncRead,
[src]
impl<R> AsyncRead for Compat01As03<R> where
R: AsyncRead,
unsafe fn initializer(&self) -> Initializer
[src]
unsafe fn initializer(&self) -> Initializer
fn poll_read(
&mut self,
lw: &LocalWaker,
buf: &mut [u8]
) -> Poll<Result<usize, Error>>
[src]
fn poll_read(
&mut self,
lw: &LocalWaker,
buf: &mut [u8]
) -> Poll<Result<usize, Error>>
fn poll_vectored_read(
&mut self,
lw: &LocalWaker,
vec: &mut [&mut IoVec]
) -> Poll<Result<usize, Error>>
[src]
fn poll_vectored_read(
&mut self,
lw: &LocalWaker,
vec: &mut [&mut IoVec]
) -> Poll<Result<usize, Error>>
impl<R> AsyncRead for ReadHalf<R> where
R: AsyncRead,
[src]
impl<R> AsyncRead for ReadHalf<R> where
R: AsyncRead,
fn poll_read(
&mut self,
lw: &LocalWaker,
buf: &mut [u8]
) -> Poll<Result<usize, Error>>
[src]
fn poll_read(
&mut self,
lw: &LocalWaker,
buf: &mut [u8]
) -> Poll<Result<usize, Error>>
fn poll_vectored_read(
&mut self,
lw: &LocalWaker,
vec: &mut [&mut IoVec]
) -> Poll<Result<usize, Error>>
[src]
fn poll_vectored_read(
&mut self,
lw: &LocalWaker,
vec: &mut [&mut IoVec]
) -> Poll<Result<usize, Error>>
unsafe fn initializer(&self) -> Initializer
[src]
unsafe fn initializer(&self) -> Initializer
impl<T> AsyncRead for AllowStdIo<T> where
T: Read,
[src]
impl<T> AsyncRead for AllowStdIo<T> where
T: Read,
fn poll_read(
&mut self,
&LocalWaker,
buf: &mut [u8]
) -> Poll<Result<usize, Error>>
[src]
fn poll_read(
&mut self,
&LocalWaker,
buf: &mut [u8]
) -> Poll<Result<usize, Error>>
unsafe fn initializer(&self) -> Initializer
[src]
unsafe fn initializer(&self) -> Initializer
fn poll_vectored_read(
&mut self,
lw: &LocalWaker,
vec: &mut [&mut IoVec]
) -> Poll<Result<usize, Error>>
[src]
fn poll_vectored_read(
&mut self,
lw: &LocalWaker,
vec: &mut [&mut IoVec]
) -> Poll<Result<usize, Error>>