XmlReader

Trait XmlReader 

Source
pub trait XmlReader: Sized {
    // Required methods
    fn resolve<'n>(
        &self,
        name: QName<'n>,
        attribute: bool,
    ) -> (ResolveResult<'_>, LocalName<'n>);
    fn namespaces(&self) -> NamespacesShared<'static>;
    fn current_position(&self) -> u64;
    fn error_position(&self) -> u64;

    // Provided methods
    fn extend_error(&self, error: Error) -> Error { ... }
    fn map_error<E>(&self, error: E) -> Error
       where Error: From<E> { ... }
    fn map_result<T, E>(&self, result: Result<T, E>) -> Result<T, Error>
       where Error: From<E> { ... }
    fn err<E>(&self, error: E) -> Result<(), Error>
       where Error: From<E> { ... }
    fn with_error_info(self) -> ErrorReader<Self> { ... }
}
Expand description

Trait that defines the basics for an XML reader.

Required Methods§

Source

fn resolve<'n>( &self, name: QName<'n>, attribute: bool, ) -> (ResolveResult<'_>, LocalName<'n>)

Resolves a qname in the current context of the XML file.

Source

fn namespaces(&self) -> NamespacesShared<'static>

Returns a map that contains all namespaces in the current context.

Source

fn current_position(&self) -> u64

Returns the current position (byte offset) in the current XML file.

Source

fn error_position(&self) -> u64

Returns the position (byte offset) of the last detected error.

Provided Methods§

Source

fn extend_error(&self, error: Error) -> Error

Add the error position to the passed error and return it.

Source

fn map_error<E>(&self, error: E) -> Error
where Error: From<E>,

Converts the passed error to an Error, adds the error information using extend_error and returns it.

Source

fn map_result<T, E>(&self, result: Result<T, E>) -> Result<T, Error>
where Error: From<E>,

Same as map_error, but for the passed result.

Source

fn err<E>(&self, error: E) -> Result<(), Error>
where Error: From<E>,

Create a result from the passed error using map_error and returns it.

Source

fn with_error_info(self) -> ErrorReader<Self>

Wraps the current reader in a new ErrorReader.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§