pub struct PiParser(pub bool);
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
processing instruction 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 you 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::reader::{Parser, PiParser};
let mut parser = PiParser::default();
// Parse `<?instruction with = 'some > and ?' inside?>and the text follow...`
// splitted into three chunks
assert_eq!(parser.feed(b"<?instruction"), 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(9));
// ^ ^
// 0 9
Tuple Fields§
§0: bool
A flag that indicates was the bytes
in the previous attempt to find the
end ended with ?
.
Trait Implementations§
source§impl Parser for PiParser
impl Parser for PiParser
source§fn feed(&mut self, bytes: &[u8]) -> Option<usize>
fn feed(&mut self, bytes: &[u8]) -> Option<usize>
Determines the end position of a processing instruction in the provided slice.
Processing instruction ends on the first occurrence of ?>
which cannot be
escaped.
Returns position after the ?>
or None
if such sequence was not found.
Section 2.6: Parameter entity references MUST NOT be recognized within processing instructions, so parser do not search for them.
§Parameters
bytes
: a slice to find the end of a processing instruction. Should contain text in ASCII-compatible encoding