Parser

Trait Parser 

Source
pub trait Parser {
    // Required methods
    fn feed(&mut self, bytes: &[u8]) -> Option<usize>;
    fn eof_error(self, content: &[u8]) -> SyntaxError;
}
Expand description

Used to decouple reading of data from data source and parsing XML structure from it. This is a state preserved between getting chunks of bytes from the reader.

This trait is implemented for every parser that processes piece of XML grammar.

Required Methods§

Source

fn feed(&mut self, bytes: &[u8]) -> Option<usize>

Process new data and try to determine end of the parsed thing.

Returns position of the end of thing in bytes in case of successful search and None otherwise.

§Parameters
  • bytes: a slice to find the end of a thing. Should contain text in ASCII-compatible encoding
Source

fn eof_error(self, content: &[u8]) -> SyntaxError

Returns parse error produced by this parser in case of reaching end of input without finding the end of a parsed thing.

§Parameters
  • content: the content that was read before EOF. Some parsers may use this to provide more specific error messages.

Implementors§