Trait AsyncReadExt
trait AsyncReadExt: AsyncRead
An extension trait which adds utility methods to AsyncRead types.
Provided Methods
fn chain<R>(self: Self, next: R) -> Chain<Self, R> where Self: Sized, R: AsyncReadCreates 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>(self: &'a mut Self, buf: &'a mut [u8]) -> Read<'a, Self> where Self: UnpinTries 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>(self: &'a mut Self, bufs: &'a mut [IoSliceMut<'a>]) -> ReadVectored<'a, Self> where Self: UnpinCreates 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>(self: &'a mut Self, buf: &'a mut [u8]) -> ReadExact<'a, Self> where Self: UnpinCreates 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>(self: &'a mut Self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self> where Self: UnpinCreates 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>(self: &'a mut Self, buf: &'a mut String) -> ReadToString<'a, Self> where Self: UnpinCreates 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: Self) -> (ReadHalf<Self>, WriteHalf<Self>) where Self: AsyncWrite + SizedHelper 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: Self, limit: u64) -> Take<Self> where Self: SizedCreates an AsyncRead adapter which will read at most
limitbytes from the underlying reader.Examples
# block_on.unwrap;
Implementors
impl<R> AsyncReadExt for Cursor<T>impl<R> AsyncReadExt for Emptyimpl<R> AsyncReadExt for Take<R>impl<R> AsyncReadExt for Chain<T, U>impl<R> AsyncReadExt for BufWriter<W>impl<R> AsyncReadExt for AllowStdIo<T>impl<R: AsyncRead + ?Sized> AsyncReadExt for Rimpl<R> AsyncReadExt for Repeatimpl<R> AsyncReadExt for IntoAsyncRead<St>impl<R> AsyncReadExt for Either<A, B>impl<R> AsyncReadExt for ReadHalf<T>impl<R> AsyncReadExt for BufReader<R>