xsd_parser::quick_xml::reader

Trait XmlReader

Source
pub trait XmlReader: Sized {
    // Required methods
    fn resolve<'n>(
        &self,
        name: QName<'n>,
        attribute: bool,
    ) -> (ResolveResult<'_>, LocalName<'n>);
    fn prefixes(&self) -> PrefixIter<'_>;
    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 read_attrib<T>(
        &self,
        store: &mut Option<T>,
        name: &'static [u8],
        value: &[u8],
    ) -> Result<(), Error>
       where T: DeserializeBytes { ... }
    fn with_error_info(self) -> ErrorReader<Self> { ... }
    fn resolve_local_name<'a>(
        &self,
        name: QName<'a>,
        ns: &[u8],
    ) -> Option<&'a [u8]> { ... }
}
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 prefixes(&self) -> PrefixIter<'_>

Returns an iterator the walks over all known namespace prefixes for the current context of the XML file.

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 read_attrib<T>( &self, store: &mut Option<T>, name: &'static [u8], value: &[u8], ) -> Result<(), Error>

Helper function to convert and store an attribute from the XML event.

§Errors

Returns an Error with ErrorKind::DuplicateAttribute if store already contained a value.

Source

fn with_error_info(self) -> ErrorReader<Self>

Wraps the current reader in a new ErrorReader.

Source

fn resolve_local_name<'a>(&self, name: QName<'a>, ns: &[u8]) -> Option<&'a [u8]>

Try to resolve the local name of the passed qname and the expected namespace.

Checks if the passed QName name matches the expected namespace ns and returns the local name of it. If name does not have a namespace prefix to resolve, the local name is just returned as is.

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§