Struct xml::reader::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) -> EventReader<R>

Creates a new reader, consuming the given stream.

source

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

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 returned event is XmlEvent::Error 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

source

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

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§

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

source

pub fn from_str(source: &'r str) -> EventReader<&'r [u8]>

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

Trait Implementations§

source§

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

§

type Item = Result<XmlEvent, Error>

The type of the elements being iterated over.
§

type IntoIter = Events<R>

Which kind of iterator are we turning this into?
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> !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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.