Trait AsyncBufReadExt
trait AsyncBufReadExt: AsyncBufRead
An extension trait which adds utility methods to AsyncBufRead types.
Provided Methods
fn fill_buf(self: &mut Self) -> FillBuf<'_, Self> where Self: UnpinCreates a future which will wait for a non-empty buffer to be available from this I/O object or EOF to be reached.
This method is the async equivalent to
BufRead::fill_buf.# block_on.unwrap;fn consume_unpin(self: &mut Self, amt: usize) where Self: UnpinA convenience for calling
AsyncBufRead::consumeonUnpinIO types.# block_on.unwrap;fn read_until<'a>(self: &'a mut Self, byte: u8, buf: &'a mut Vec<u8>) -> ReadUntil<'a, Self> where Self: UnpinCreates a future which will read all the bytes associated with this I/O object into
bufuntil the delimiterbyteor EOF is reached. This method is the async equivalent toBufRead::read_until.This function will read bytes from the underlying stream until the delimiter or EOF is found. Once found, all bytes up to, and including, the delimiter (if found) will be appended to
buf.The returned future will resolve to the number of bytes read 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;fn read_line<'a>(self: &'a mut Self, buf: &'a mut String) -> ReadLine<'a, Self> where Self: UnpinCreates a future which will read all the bytes associated with this I/O object into
bufuntil a newline (the 0xA byte) or EOF is reached, This method is the async equivalent toBufRead::read_line.This function will read bytes from the underlying stream until the newline delimiter (the 0xA byte) or EOF is found. Once found, all bytes up to, and including, the delimiter (if found) will be appended to
buf.The returned future will resolve to the number of bytes read once the read operation is completed.
In the case of an error the buffer and the object will be discarded, with the error yielded.
Errors
This function has the same error semantics as
read_untiland will also return an error if the read bytes are not valid UTF-8. If an I/O error is encountered thenbufmay contain some bytes already read in the event that all data read so far was valid UTF-8.Examples
# block_on.unwrap;fn lines(self: Self) -> Lines<Self> where Self: SizedReturns a stream over the lines of this reader. This method is the async equivalent to
BufRead::lines.The stream returned from this function will yield instances of
io::Result<String>. Each string returned will not have a newline byte (the 0xA byte) or CRLF (0xD, 0xA bytes) at the end.Errors
Each line of the stream has the same error semantics as
AsyncBufReadExt::read_line.Examples
# block_on.unwrap;
Implementors
impl<R> AsyncBufReadExt for BufWriter<W>impl<R> AsyncBufReadExt for AllowStdIo<T>impl<R> AsyncBufReadExt for Either<A, B>impl<R: AsyncBufRead + ?Sized> AsyncBufReadExt for Rimpl<R> AsyncBufReadExt for Emptyimpl<R> AsyncBufReadExt for BufReader<R>impl<R> AsyncBufReadExt for Take<R>impl<R> AsyncBufReadExt for Chain<T, U>impl<R> AsyncBufReadExt for Cursor<T>impl<R> AsyncBufReadExt for IntoAsyncRead<St>