pub enum CommentParser {
Seen0,
Seen1,
Seen2,
}Expand description
A parser that search a --> sequence in the slice.
To use a parser create an instance of parser and feed data into it.
After successful search the parser will return Some with position where
comment is ended (the position after -->). If search was unsuccessful,
a None will be returned. You typically would expect positive result of
search, so that you should feed new data until yo’ll get it.
NOTE: after successful match the parser does not returned to the initial state and should not be used anymore. Create a new parser if you want to perform new search.
§Example
use quick_xml::parser::{CommentParser, Parser};
let mut parser = CommentParser::default();
// Parse `<!-- comment with some -> and --- inside-->and the text follow...`
// splitted into three chunks
assert_eq!(parser.feed(b"<!-- comment"), None);
// ...get new chunk of data
assert_eq!(parser.feed(b" with some -> and -"), None);
// ...get another chunk of data
assert_eq!(parser.feed(b"-- inside-->and the text follow..."), Some(12));
// ^ ^
// 0 11Variants§
Seen0
The parser does not yet seen any dashes at the end of previous slice.
Seen1
The parser already seen one dash on the end of previous slice.
Seen2
The parser already seen two dashes on the end of previous slice.
Trait Implementations§
Source§impl Clone for CommentParser
impl Clone for CommentParser
Source§fn clone(&self) -> CommentParser
fn clone(&self) -> CommentParser
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CommentParser
impl Debug for CommentParser
Source§impl Default for CommentParser
impl Default for CommentParser
Source§impl Parser for CommentParser
impl Parser for CommentParser
Source§fn feed(&mut self, bytes: &[u8]) -> Option<usize>
fn feed(&mut self, bytes: &[u8]) -> Option<usize>
Determines the end position of an XML comment in the provided slice.
Comments is a pieces of text enclosed in <!-- and --> braces.
Comment ends on the first occurrence of --> which cannot be escaped.
Returns position after the --> or None if such sequence was not found.
§Parameters
bytes: a slice to find the end of a comment. Should contain text in ASCII-compatible encoding