pub struct XmlByteStreamReader<R: Read> { /* private fields */ }Expand description
Streaming XML reader that pulls bytes from an io::Read source
on demand.
Constructed via Self::new or Self::with_size_hint and
then driven via Self::next_event (pull events one at a time)
or Self::validate (drive to EOF for a well-formedness check).
Implementations§
Source§impl<R: Read> XmlByteStreamReader<R>
impl<R: Read> XmlByteStreamReader<R>
Sourcepub fn new(inner: R, buffer_size: usize) -> Result<Self>
pub fn new(inner: R, buffer_size: usize) -> Result<Self>
Construct with no size hint (e.g. stdin). Starts with a
64 KiB buffer that grows as needed up to buffer_size.
Sourcepub fn with_size_hint(
inner: R,
size_hint: Option<usize>,
buffer_size: usize,
) -> Result<Self>
pub fn with_size_hint( inner: R, size_hint: Option<usize>, buffer_size: usize, ) -> Result<Self>
Construct with an optional size hint. When the input’s
total size is known (file with stat-derived length), pass it
— the wrapper pre-allocates exactly that much (capped by
buffer_size), avoiding the per-growth memcpy cost. For
stdin / pipes, pass None and the buffer grows
incrementally from a 64 KiB seed.
Sourcepub fn with_options(self, opts: ParseOptions) -> Self
pub fn with_options(self, opts: ParseOptions) -> Self
Override the inner reader’s ParseOptions. See
XmlBytesReader::with_options for what’s tunable.
Note: opts.stream_owned_names is forced to true
regardless of what the caller passes — the streaming
wrapper requires owned element names to survive buffer
compaction between events.
Sourcepub fn xml_decl(&self) -> Option<&XmlDeclInfo>
pub fn xml_decl(&self) -> Option<&XmlDeclInfo>
XML declaration fields parsed from the prolog, if any.
Returns None before the first event has been pulled.
Sourcepub fn recovered_errors(&self) -> &[XmlError]
pub fn recovered_errors(&self) -> &[XmlError]
Non-fatal errors logged while
ParseOptions::recovery_mode is enabled. Empty otherwise.
Sourcepub fn next_event(&mut self) -> Result<BytesEvent<'_, '_>>
pub fn next_event(&mut self) -> Result<BytesEvent<'_, '_>>
Pull the next parse event, streaming more bytes from the source as needed.
The returned BytesEvent borrows the reader’s internal
rolling buffer and is valid only until the next call to
next_event (or any other &mut self method): its lifetime is
tied to the &mut self borrow, so the borrow checker forbids
pulling the next event while one is still held. Consume each
event (copy out what you need) before requesting the next —
the same zero-copy contract as XmlBytesReader::next.
Yields BytesEvent::Eof once the document is exhausted; a
well-formedness violation surfaces as Err.
Sourcepub fn validate(self) -> Result<()>
pub fn validate(self) -> Result<()>
Drive the parser to EOF. Returns Ok(()) if every event up
through BytesEvent::Eof parses without error. This is the
CLI’s lint workload — we don’t need the events themselves,
just the well-formedness verdict.