Skip to main content

XMLStreamReader

Struct XMLStreamReader 

Source
pub struct XMLStreamReader<'a, Resolver: EntityResolver = DefaultSAXHandler, Reporter: ErrorHandler = DefaultSAXHandler> { /* private fields */ }

Implementations§

Source§

impl<'a, Resolver: EntityResolver> XMLStreamReader<'a, Resolver>

Source

pub fn last_error(&self) -> Option<&SAXParseError>

Returns the most recently occurred warning, error, or fatal error.
If none occurred, returns None.

When no user-defined error handler is configured, this method can be used to catch errors other than unrecoverable errors.
To catch all errors that occur during the parsing process, a user-defined error handler must be configured.

Source§

impl<'a, Resolver: EntityResolver, Reporter: ErrorHandler> XMLStreamReader<'a, Resolver, Reporter>

Source

pub fn parse_uri( &mut self, uri: impl AsRef<URIStr>, encoding: Option<&str>, ) -> Result<(), XMLError>

Retrieves and parses the XML document specified by uri.
If retrieval or parsing of the XML document fails, an error is returned.

The preferred encoding can be specified using encoding.

Source

pub fn parse_reader( &mut self, reader: impl Read + 'a, encoding: Option<&str>, uri: Option<&URIStr>, ) -> Result<(), XMLError>

The data read from reader is parsed as an XML document.
If parsing of the XML document fails, an error is returned.

The preferred encoding can be specified using encoding.

uri is treated as the document’s base URI. It is optional to set, but may be required if the document being parsed references external resources.

Source

pub fn parse_str( &mut self, xml: &str, uri: Option<&URIStr>, ) -> Result<(), XMLError>

Parses xml as an XML document.
If parsing of the XML document fails, an error is returned.

Assumes the document is encoded in UTF-8.

uri is treated as the document’s base URI. It is optional to set, but may be required if the document being parsed references external resources.

Source

pub fn reset(&mut self) -> Result<(), XMLError>

Reset parser.

Source

pub fn next_event<'b>(&'b mut self) -> Result<XMLEvent<'b>, XMLError>

Advance the event until next markup or text data.

Source

pub fn next_tag<'b>(&'b mut self) -> Result<XMLEvent<'b>, XMLError>

Advance the event until the tag-related event appears.

Source

pub fn namespaces(&self) -> &NamespaceStack

Current namespace stack.

Source

pub fn locator(&self) -> Option<Arc<Locator>>

Returns a valid locator if exists.
The returned locator is valid from after the StartDocument event until before parsing ends due to the EndDocument event or a fatal error.
Outside the locator’s valid range, it returns None.

Source

pub fn error_handler(&self) -> Option<&Reporter>

If a user-defined error handler is configured, it will be returned.

Source

pub fn set_error_handler(&mut self, handler: Reporter) -> Option<Reporter>

Configure a user-defined error handler. If a handler is already configured, return it.

Source

pub fn take_error_handler(&mut self) -> Option<Reporter>

If a user-defined error handler is configured, it will be returned.
The error handler will be unset.

Trait Implementations§

Source§

impl Default for XMLStreamReader<'_>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a, Resolver, Reporter> Freeze for XMLStreamReader<'a, Resolver, Reporter>
where Resolver: Freeze, Reporter: Freeze,

§

impl<'a, Resolver = DefaultSAXHandler, Reporter = DefaultSAXHandler> !RefUnwindSafe for XMLStreamReader<'a, Resolver, Reporter>

§

impl<'a, Resolver = DefaultSAXHandler, Reporter = DefaultSAXHandler> !Send for XMLStreamReader<'a, Resolver, Reporter>

§

impl<'a, Resolver = DefaultSAXHandler, Reporter = DefaultSAXHandler> !Sync for XMLStreamReader<'a, Resolver, Reporter>

§

impl<'a, Resolver, Reporter> Unpin for XMLStreamReader<'a, Resolver, Reporter>
where Resolver: Unpin, Reporter: Unpin,

§

impl<'a, Resolver = DefaultSAXHandler, Reporter = DefaultSAXHandler> !UnwindSafe for XMLStreamReader<'a, Resolver, Reporter>

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.