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§
Sourcefn resolve<'n>(
&self,
name: QName<'n>,
attribute: bool,
) -> (ResolveResult<'_>, LocalName<'n>)
fn resolve<'n>( &self, name: QName<'n>, attribute: bool, ) -> (ResolveResult<'_>, LocalName<'n>)
Resolves a qname in the current context of the XML file.
Sourcefn prefixes(&self) -> PrefixIter<'_>
fn prefixes(&self) -> PrefixIter<'_>
Returns an iterator the walks over all known namespace prefixes for the current context of the XML file.
Sourcefn current_position(&self) -> u64
fn current_position(&self) -> u64
Returns the current position (byte offset) in the current XML file.
Sourcefn error_position(&self) -> u64
fn error_position(&self) -> u64
Returns the position (byte offset) of the last detected error.
Provided Methods§
Sourcefn extend_error(&self, error: Error) -> Error
fn extend_error(&self, error: Error) -> Error
Add the error position to the passed error and return it.
Sourcefn map_error<E>(&self, error: E) -> Error
fn map_error<E>(&self, error: E) -> Error
Converts the passed error to an Error, adds the error information
using extend_error and returns it.
Sourcefn map_result<T, E>(&self, result: Result<T, E>) -> Result<T, Error>
fn map_result<T, E>(&self, result: Result<T, E>) -> Result<T, Error>
Same as map_error, but for the passed result.
Sourcefn err<E>(&self, error: E) -> Result<(), Error>
fn err<E>(&self, error: E) -> Result<(), Error>
Create a result from the passed error using map_error and returns it.
Sourcefn read_attrib<T>(
&self,
store: &mut Option<T>,
name: &'static [u8],
value: &[u8],
) -> Result<(), Error>where
T: DeserializeBytes,
fn read_attrib<T>(
&self,
store: &mut Option<T>,
name: &'static [u8],
value: &[u8],
) -> Result<(), Error>where
T: DeserializeBytes,
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.
Sourcefn with_error_info(self) -> ErrorReader<Self>
fn with_error_info(self) -> ErrorReader<Self>
Wraps the current reader in a new ErrorReader.
Sourcefn resolve_local_name<'a>(&self, name: QName<'a>, ns: &[u8]) -> Option<&'a [u8]>
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.