Trait BufRead
pub trait BufRead: Read {
// Required methods
fn fill_buf(&mut self) -> Result<&[u8], AxErrorKind>;
fn consume(&mut self, amt: usize);
// Provided methods
fn has_data_left(&mut self) -> Result<bool, AxErrorKind> { ... }
fn read_until(
&mut self,
byte: u8,
buf: &mut Vec<u8>,
) -> Result<usize, AxErrorKind> { ... }
fn read_line(&mut self, buf: &mut String) -> Result<usize, AxErrorKind> { ... }
}Expand description
A BufRead is a type of Reader which has an internal buffer, allowing it
to perform extra ways of reading.
Required Methods§
fn fill_buf(&mut self) -> Result<&[u8], AxErrorKind>
fn fill_buf(&mut self) -> Result<&[u8], AxErrorKind>
Returns the contents of the internal buffer, filling it with more data from the inner reader if it is empty.
Provided Methods§
fn has_data_left(&mut self) -> Result<bool, AxErrorKind>
fn has_data_left(&mut self) -> Result<bool, AxErrorKind>
Check if the underlying Read has any data left to be read.
fn read_until(
&mut self,
byte: u8,
buf: &mut Vec<u8>,
) -> Result<usize, AxErrorKind>
fn read_until( &mut self, byte: u8, buf: &mut Vec<u8>, ) -> Result<usize, AxErrorKind>
Read all bytes into buf until the delimiter byte or EOF is reached.
fn read_line(&mut self, buf: &mut String) -> Result<usize, AxErrorKind>
fn read_line(&mut self, buf: &mut String) -> Result<usize, AxErrorKind>
Read all bytes until a newline (the 0xA byte) is reached, and append
them to the provided String buffer.