quick_xml::name

Struct NamespaceResolver

source
pub(crate) struct NamespaceResolver {
    buffer: Vec<u8>,
    bindings: Vec<NamespaceEntry>,
    nesting_level: i32,
}
Expand description

A namespace management buffer.

Holds all internal logic to push/pop namespaces with their levels.

Fields§

§buffer: Vec<u8>

Buffer that contains names of namespace prefixes (the part between xmlns: and an =) and namespace values.

§bindings: Vec<NamespaceEntry>

A stack of namespace bindings to prefixes that currently in scope

§nesting_level: i32

The number of open tags at the moment. We need to keep track of this to know which namespace declarations to remove when we encounter an End event.

Implementations§

source§

impl NamespaceResolver

source

pub fn push(&mut self, start: &BytesStart<'_>) -> Result<()>

Begins a new scope and add to it all [namespace bindings] that found in the specified start element.

source

pub fn pop(&mut self)

Ends a top-most scope by popping all namespace binding, that was added by last call to Self::push().

source

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

Resolves a potentially qualified element name or attribute name into (namespace name, local name).

Qualified names have the form prefix:local-name where the prefix is defined on any containing XML element via xmlns:prefix="the:namespace:uri". The namespace prefix can be defined on the same element as the element or attribute in question.

Unqualified attribute names do not inherit the current default namespace.

§Lifetimes
  • 'n: lifetime of an attribute or an element name
source

pub fn find(&self, element_name: QName<'_>) -> ResolveResult<'_>

Finds a namespace name for a given qualified element name, borrow it from the internal buffer.

Returns None, if:

  • name is unqualified
  • prefix not found in the current scope
  • prefix was unbound using xmlns:prefix=""
source

fn resolve_prefix( &self, prefix: Option<Prefix<'_>>, use_default: bool, ) -> ResolveResult<'_>

source

fn maybe_unknown(prefix: Option<Prefix<'_>>) -> ResolveResult<'static>

source

pub const fn iter(&self) -> PrefixIter<'_>

Trait Implementations§

source§

impl Clone for NamespaceResolver

source§

fn clone(&self) -> NamespaceResolver

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for NamespaceResolver

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for NamespaceResolver

source§

fn default() -> Self

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

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.