pub trait AsyncBufReadExt: AsyncBufRead {
// Provided methods
fn ended(&self) -> bool
where Self: Unpin { ... }
fn buffer(&self) -> &[u8] ⓘ
where Self: Unpin { ... }
fn peek(&mut self, amt: usize) -> Peek<'_, Self>
where Self: Unpin { ... }
fn consume(&mut self, amt: usize)
where Self: Unpin { ... }
}Expand description
An extension trait which adds utility methods to AsyncBufRead types.
Provided Methods§
Sourcefn peek(&mut self, amt: usize) -> Peek<'_, Self>where
Self: Unpin,
fn peek(&mut self, amt: usize) -> Peek<'_, Self>where
Self: Unpin,
Peek into the content of the internal buffer, filling it with more data from the inner reader if it less than the requested amount.
This function doesn’t consume the data, it only returns a slice up
to the requested amount. This means that subsequent calls to read
will return the same contents. As such, consume can be called
with the number of bytes that are consumed from this buffer to
ensure that the bytes are not returned by read.
To check if the inner reader has reached EOF, use ended.
Equivalent to:
async fn peek(&mut self, amt: usize) -> io::Result<&[u8]>;§Errors
This function will return an I/O error if the underlying reader was read, but returned an error.
§Cancel safety
This method is cancel safe. If you use it as the event in a
select! statement and some other branch completes first,
then it is guaranteed that no data was read.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.