pub trait BufRead: Read {
// Required methods
fn fill_buf(&mut self) -> Result<&[u8], IoError>;
fn consume(&mut self, amount: usize);
// Provided methods
fn has_data_left(&mut self) -> Result<bool, IoError> { ... }
fn skip_until(&mut self, byte: u8) -> Result<usize, IoError> { ... }
fn read_until(
&mut self,
byte: u8,
buf: &mut Vec<u8>,
) -> Result<usize, IoError> { ... }
fn read_line(&mut self, buf: &mut String) -> Result<usize, IoError> { ... }
fn split(self, byte: u8) -> Split<Self> ⓘ
where Self: Sized { ... }
fn lines(self) -> Lines<Self> ⓘ
where Self: Sized { ... }
}Expand description
A BufRead is a type of Reader which has an internal buffer, allowing it
to perform extra ways of reading.
See [std::io::BufRead] for more details.
Required Methods§
Provided Methods§
Sourcefn has_data_left(&mut self) -> Result<bool, IoError>
fn has_data_left(&mut self) -> Result<bool, IoError>
Checks if there is any data left to be read.
Sourcefn skip_until(&mut self, byte: u8) -> Result<usize, IoError>
fn skip_until(&mut self, byte: u8) -> Result<usize, IoError>
Skips all bytes until the delimiter byte or EOF is reached.
Sourcefn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<usize, IoError>
Available on crate feature alloc only.
fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<usize, IoError>
alloc only.Read all bytes into buf until the delimiter byte or EOF is reached.
Sourcefn read_line(&mut self, buf: &mut String) -> Result<usize, IoError>
Available on crate feature alloc only.
fn read_line(&mut self, buf: &mut String) -> Result<usize, IoError>
alloc only.Read all bytes until a newline (the 0xA byte) is reached, and append
them to the provided String buffer.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<B> BufRead for &mut B
impl<B> BufRead for &mut B
fn fill_buf(&mut self) -> Result<&[u8], IoError>
fn consume(&mut self, amt: usize)
fn has_data_left(&mut self) -> Result<bool, IoError>
fn skip_until(&mut self, byte: u8) -> Result<usize, IoError>
Source§impl<B> BufRead for Box<B>
Available on crate feature alloc only.
impl<B> BufRead for Box<B>
Available on crate feature
alloc only.