Skip to main content

BufRead

Trait BufRead 

Source
pub trait BufRead: Read {
    // Required methods
    fn fill_buf(&mut self) -> Result<&[u8], AxError>;
    fn consume(&mut self, amount: usize);

    // Provided methods
    fn has_data_left(&mut self) -> Result<bool, AxError> { ... }
    fn skip_until(&mut self, byte: u8) -> Result<usize, AxError> { ... }
}
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§

Source

fn fill_buf(&mut self) -> Result<&[u8], AxError>

Returns the contents of the internal buffer, filling it with more data, via Read methods, if empty.

Source

fn consume(&mut self, amount: usize)

Marks the given amount of additional bytes from the internal buffer as having been read. Subsequent calls to read only return bytes that have not been marked as read.

Provided Methods§

Source

fn has_data_left(&mut self) -> Result<bool, AxError>

Checks if there is any data left to be read.

Source

fn skip_until(&mut self, byte: u8) -> Result<usize, AxError>

Skips all bytes until the delimiter byte or EOF is reached.

Implementations on Foreign Types§

Source§

impl BufRead for &[u8]

Source§

fn fill_buf(&mut self) -> Result<&[u8], AxError>

Source§

fn consume(&mut self, amt: usize)

Source§

impl<B> BufRead for &mut B
where B: BufRead + ?Sized,

Source§

fn fill_buf(&mut self) -> Result<&[u8], AxError>

Source§

fn consume(&mut self, amt: usize)

Source§

fn has_data_left(&mut self) -> Result<bool, AxError>

Source§

fn skip_until(&mut self, byte: u8) -> Result<usize, AxError>

Implementors§

Source§

impl BufRead for Empty

Source§

impl BufRead for StdinLock<'_>

Source§

impl<R> BufRead for BufReader<R>
where R: Read + ?Sized,

Source§

impl<T> BufRead for Cursor<T>
where T: AsRef<[u8]>,

Source§

impl<T> BufRead for Take<T>
where T: BufRead,

Source§

impl<T, U> BufRead for Chain<T, U>
where T: BufRead, U: BufRead,