xml::reader

Struct EventReader

Source
pub struct EventReader<R: Read> { /* private fields */ }
Expand description

A wrapper around an std::io::Read instance which provides pull-based XML parsing.

Implementations§

Source§

impl<R: Read> EventReader<R>

Source

pub fn new(source: R) -> Self

Creates a new reader, consuming the given stream.

Source

pub fn new_with_config(source: R, config: impl Into<ParserConfig2>) -> Self

Creates a new reader with the provded configuration, consuming the given stream.

Source

pub fn next(&mut self) -> Result<XmlEvent>

Pulls and returns next XML event from the stream.

If this returns Err or XmlEvent::EndDocument then further calls to this method will return this event again.

Source

pub fn skip(&mut self) -> Result<()>

Skips all XML events until the next end tag at the current level.

Convenience function that is useful for the case where you have encountered a start tag that is of no interest and want to skip the entire XML subtree until the corresponding end tag.

Source

pub fn source(&self) -> &R

Access underlying reader

Using it directly while the event reader is parsing is not recommended

Source

pub fn source_mut(&mut self) -> &mut R

Access underlying reader

Using it directly while the event reader is parsing is not recommended

Source

pub fn into_inner(self) -> R

Unwraps this EventReader, returning the underlying reader.

Note that this operation is destructive; unwrapping the reader and wrapping it again with EventReader::new() will create a fresh reader which will attempt to parse an XML document from the beginning.

Source

pub fn doctype(&self) -> Option<&str>

Returns the DOCTYPE of the document if it has already been seen

Available only after the root StartElement event

Source§

impl<'r> EventReader<&'r [u8]>

Source

pub fn from_str(source: &'r str) -> Self

A convenience method to create an XmlReader from a string slice.

Trait Implementations§

Source§

impl<R: Read> IntoIterator for EventReader<R>

Source§

type IntoIter = Events<R>

Which kind of iterator are we turning this into?
Source§

type Item = Result<XmlEvent, Error>

The type of the elements being iterated over.
Source§

fn into_iter(self) -> Events<R>

Creates an iterator from a value. Read more
Source§

impl<B: Read> Position for EventReader<B>

Source§

fn position(&self) -> TextPosition

Returns the position of the last event produced by the reader.

Auto Trait Implementations§

§

impl<R> Freeze for EventReader<R>
where R: Freeze,

§

impl<R> !RefUnwindSafe for EventReader<R>

§

impl<R> Send for EventReader<R>
where R: Send,

§

impl<R> Sync for EventReader<R>
where R: Sync,

§

impl<R> Unpin for EventReader<R>
where R: Unpin,

§

impl<R> !UnwindSafe for EventReader<R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.