ParseBuf

Trait ParseBuf 

Source
pub unsafe trait ParseBuf<'p> {
    // Required methods
    fn chunk(&mut self) -> ParseResult<ParseBufChunk<'_, 'p>>;
    fn advance(&mut self, count: usize);

    // Provided method
    fn remaining_hint(&self) -> Option<usize> { ... }
}
Expand description

A data source from which Parser can parse data.

A ParseBuf has two main components:

  • An internal buffer that stores some amount of data. chunk returns a view into this buffer.
  • A position, advance moves this forward.

§Safety

  • If remaining_hint returns Some then the returned value must be accurate.

Required Methods§

Source

fn chunk(&mut self) -> ParseResult<ParseBufChunk<'_, 'p>>

Returns a chunk starting at the current position.

This method must never return an empty chunk. If an empty chunk would be returned, it should return an error instead. ParseError::eof has been provided for this, though it is not required to use it.

This method must keep returning the same data until advance has been called to move past it.

See the documentation for ParseBufChunk for an explanation on when to use ParseBufChunk::Temporary vs ParseBufChunk::External.

Source

fn advance(&mut self, count: usize)

Advance this buffer past count bytes.

Provided Methods§

Source

fn remaining_hint(&self) -> Option<usize>

An indicator of how many bytes are left, if supported.

This is used for some optimizations within Parser, if Some is returned then the value must be accurate.

Implementations on Foreign Types§

Source§

impl<'p> ParseBuf<'p> for &'p [u8]

Source§

fn chunk(&mut self) -> ParseResult<ParseBufChunk<'_, 'p>>

Source§

fn advance(&mut self, count: usize)

Source§

fn remaining_hint(&self) -> Option<usize>

Source§

impl<'p, R> ParseBuf<'p> for BufReader<R>
where R: Read,

Source§

fn chunk(&mut self) -> ParseResult<ParseBufChunk<'_, 'p>>

Source§

fn advance(&mut self, count: usize)

Implementors§