pub struct XmlStreamReader<R: BufRead> { /* private fields */ }Expand description
A streaming XML reader that enforces XmlSafetyPolicy without retaining a full document.
Implementations§
Source§impl<R: BufRead> XmlStreamReader<R>
impl<R: BufRead> XmlStreamReader<R>
Sourcepub fn new(reader: R, policy: XmlSafetyPolicy) -> Result<Self, Error>
pub fn new(reader: R, policy: XmlSafetyPolicy) -> Result<Self, Error>
Sourcepub fn read_event(&mut self) -> Result<XmlStreamEvent<'_>, Error>
pub fn read_event(&mut self) -> Result<XmlStreamEvent<'_>, Error>
Reads and validates the next XML event.
§Errors
Returns an error for underlying I/O failures, malformed or invalidly encoded XML, forbidden document constructs, or any configured safety-limit violation.
Sourcepub fn read_text_current(&mut self) -> Result<String, Error>
pub fn read_text_current(&mut self) -> Result<String, Error>
Reads direct text and CDATA until the end of the current start element.
§Errors
Returns an error when no current start element is available, a nested element is found, or event reading or XML validation fails.
Sourcepub fn skip_current(&mut self) -> Result<(), Error>
pub fn skip_current(&mut self) -> Result<(), Error>
Skips the current start element and all descendants with constant retained memory.
§Errors
Returns an error when no current start element is available, nesting overflows, the document ends early, or event reading or XML validation fails.
Sourcepub fn capture_current(
&mut self,
max_bytes: usize,
) -> Result<ValidatedXml, Error>
pub fn capture_current( &mut self, max_bytes: usize, ) -> Result<ValidatedXml, Error>
Materializes only the current subtree as a validated owned XML value.
§Errors
Returns an error when no current start element is available, max_bytes is zero, namespace
synthesis or event decoding fails, the subtree exceeds its output bound, or the captured XML
fails validation.