Trait AsyncReadExt
pub trait AsyncReadExt: AsyncRead
An extension trait which adds utility methods to AsyncRead types.
Provided Methods
fn chain<R>(self, next: R) -> Chain<Self, R> where Self: Sized, R: AsyncRead,Creates an adaptor which will chain this stream with another.
The returned
AsyncReadinstance will first read all bytes from this object until EOF is encountered. Afterwards the output is equivalent to the output ofnext.Examples
# block_on.unwrap;fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self> where Self: Unpin,Tries to read some bytes directly into the given
bufin asynchronous manner, returning a future type.The returned future will resolve to the number of bytes read once the read operation is completed.
Examples
# block_on.unwrap;fn read_vectored<'a>(&'a mut self, bufs: &'a mut [IoSliceMut<'a>]) -> ReadVectored<'a, Self> where Self: Unpin,Creates a future which will read from the
AsyncReadintobufsusing vectored IO operations.The returned future will resolve to the number of bytes read once the read operation is completed.
fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self> where Self: Unpin,Creates a future which will read exactly enough bytes to fill
buf, returning an error if end of file (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.
Examples
# block_on.unwrap;EOF is hit before
bufis filled# block_on;fn read_to_end<'a>(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self> where Self: Unpin,Creates a future which will read all the bytes from this
AsyncRead.On success the total number of bytes read is returned.
Examples
# block_on.unwrap;fn read_to_string<'a>(&'a mut self, buf: &'a mut String) -> ReadToString<'a, Self> where Self: Unpin,Creates a future which will read all the bytes from this
AsyncRead.On success the total number of bytes read is returned.
Examples
# block_on.unwrap;fn split(self) -> (ReadHalf<Self>, WriteHalf<Self>) where Self: AsyncWrite + Sized,Helper method for splitting this read/write object into two halves.
The two halves returned implement the
AsyncReadandAsyncWritetraits, respectively.Examples
# block_on.unwrap;fn take(self, limit: u64) -> Take<Self> where Self: Sized,Creates an AsyncRead adapter which will read at most
limitbytes from the underlying reader.Examples
# block_on.unwrap;
Implementors
impl<R> AsyncReadExt for AllowStdIo<T> where R: AsyncRead + ?Sized,impl<R> AsyncReadExt for BufReader<R> where R: AsyncRead + ?Sized,impl<R> AsyncReadExt for BufWriter<W> where R: AsyncRead + ?Sized,impl<R> AsyncReadExt for Chain<T, U> where R: AsyncRead + ?Sized,impl<R> AsyncReadExt for Cursor<T> where R: AsyncRead + ?Sized,impl<R> AsyncReadExt for Either<A, B> where R: AsyncRead + ?Sized,impl<R> AsyncReadExt for Empty where R: AsyncRead + ?Sized,impl<R> AsyncReadExt for IntoAsyncRead<St> where R: AsyncRead + ?Sized,impl<R> AsyncReadExt for ReadHalf<T> where R: AsyncRead + ?Sized,impl<R> AsyncReadExt for Repeat where R: AsyncRead + ?Sized,impl<R> AsyncReadExt for Take<R> where R: AsyncRead + ?Sized,impl<R: AsyncRead + ?Sized> AsyncReadExt for R