-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move
Parser
, ElementParser
and PiParser
to the new module `pars…
…er`.
- Loading branch information
Showing
9 changed files
with
45 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//! Contains low-level parsers of different XML pieces. | ||
use crate::errors::SyntaxError; | ||
|
||
mod element; | ||
mod pi; | ||
|
||
pub use element::ElementParser; | ||
pub use pi::PiParser; | ||
|
||
/// 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. | ||
pub trait Parser { | ||
/// 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 | ||
fn feed(&mut self, bytes: &[u8]) -> Option<usize>; | ||
|
||
/// Returns parse error produced by this parser in case of reaching end of | ||
/// input without finding the end of a parsed thing. | ||
fn eof_error() -> SyntaxError; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters