pub trait BufRead: Read {
// Required methods
async fn fill_buf(&mut self) -> Result<&[u8], Self::Error>;
fn consume(&mut self, amt: usize);
}
Expand description
Async buffered reader.
This trait is the embedded-io-async
equivalent of std::io::BufRead
.
Required Methods§
Sourceasync fn fill_buf(&mut self) -> Result<&[u8], Self::Error>
async fn fill_buf(&mut self) -> Result<&[u8], Self::Error>
Return the contents of the internal buffer, filling it with more data from the inner reader if it is empty.
If no bytes are currently available to read, this function waits until at least one byte is available.
If the reader is at end-of-file (EOF), an empty slice is returned. There is no guarantee that a reader at EOF will always be so in the future, for example a reader can stop being at EOF if another process appends more bytes to the underlying file.
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.
Implementations on Foreign Types§
Source§impl BufRead for VecDeque<u8>
Available on crate features std
or alloc
only.BufRead is implemented for VecDeque<u8>
by reading bytes from the front of the VecDeque
.
impl BufRead for VecDeque<u8>
std
or alloc
only.BufRead is implemented for VecDeque<u8>
by reading bytes from the front of the VecDeque
.
Source§async fn fill_buf(&mut self) -> Result<&[u8], Self::Error>
async fn fill_buf(&mut self) -> Result<&[u8], Self::Error>
Returns the contents of the “front” slice as returned by
as_slices
. If the contained byte slices of the VecDeque
are
discontiguous, multiple calls to fill_buf
will be needed to read the entire content.