[][src]Trait linux::util::io::BufRead

pub trait BufRead: Read {
    fn copy_until<W: Write>(&mut self, dst: &mut W, b: u8) -> Result<usize>;
fn consume(&mut self, num: usize) -> usize; }

Objects that wrap a byte-stream for reading and contain a buffer.

Required methods

fn copy_until<W: Write>(&mut self, dst: &mut W, b: u8) -> Result<usize>

Copies bytes from the stream to a writer until a certain byte occurs.

[argument, dst] The writer into which the stream will be piped.

[argument, b] The byte at which to stop.

[return_value] Returns the total number of bytes copied.

= Remarks

The stop-byte itself is copied to the destination. The copied bytes are no longer available for further read operations. If an error occurs, the error is returned immediately. In this case no bytes are lost since all read bytes have already been copied to the dst variable. The number of copied bytes is lost unless the dst variable has a means to obtain the number of copied bytes.

fn consume(&mut self, num: usize) -> usize

Removes a certain number of bytes from the buffer.

[argument, num] The number of bytes to remove.

[return_value] Returns the actual number of bytes removed.

= Remarks

The returned value can be less than the num argument because there are fewer than num bytes currently buffered.

Loading content...

Implementations on Foreign Types

impl<'a> BufRead for &'a [u8][src]

Loading content...

Implementors

Loading content...