Trait axstd::io::prelude::BufRead

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

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

Required Methods§

source

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

Returns the contents of the internal buffer, filling it with more data from the inner reader if it is empty.

source

fn consume(&mut self, amt: usize)

Tells this buffer that amt bytes have been consumed from the buffer, so they should no longer be returned in calls to read.

Provided Methods§

source

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

Check if the underlying Read has any data left to be read.

source

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

Available on crate feature alloc only.

Read all bytes into buf until the delimiter byte or EOF is reached.

source

fn read_line(&mut self, buf: &mut String) -> Result<usize, AxError>

Available on crate feature alloc only.

Read all bytes until a newline (the 0xA byte) is reached, and append them to the provided String buffer.

Implementors§

source§

impl BufRead for StdinLock<'_>

source§

impl<R> BufRead for BufReader<R>
where R: Read,