Trait futures::prelude::AsyncReadExt [−][src]
pub trait AsyncReadExt: AsyncRead { fn copy_into<W>(&'a mut self, writer: &'a mut W) -> CopyInto<'a, Self, W>
where
W: AsyncWrite, { ... } fn read(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self> { ... } fn read_exact(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self> { ... } fn read_to_end(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self> { ... } fn split(self) -> (ReadHalf<Self>, WriteHalf<Self>)
where
Self: AsyncWrite, { ... } }
An extension trait which adds utility methods to AsyncRead
types.
Provided Methods
fn copy_into<W>(&'a mut self, writer: &'a mut W) -> CopyInto<'a, Self, W> where
W: AsyncWrite,
W: AsyncWrite,
Creates a future which copies all the bytes from one object to another.
The returned future will copy all the bytes read from this AsyncRead
into the
writer
specified. This future will only complete once the reader
has hit
EOF and all bytes have been written to and flushed from the writer
provided.
On success the number of bytes is returned.
fn read(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self>
Tries to read some bytes directly into the given buf
in asynchronous
manner, returning a future type.
The returned future will resolve to the number of bytes read once the read operation is completed.
fn read_exact(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self>
Creates a future which will read exactly enough bytes to fill buf
,
returning an error if EOF is hit sooner.
The returned future will resolve once the read operation is completed.
In the case of an error the buffer and the object will be discarded, with the error yielded.
fn read_to_end(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self>
Creates a future which will read all the bytes from this AsyncRead
.
fn split(self) -> (ReadHalf<Self>, WriteHalf<Self>) where
Self: AsyncWrite,
Self: AsyncWrite,
Helper method for splitting this read/write object into two halves.
The two halves returned implement the Read
and Write
traits,
respectively.