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
impl NamespaceResolver
sourcepub fn push(&mut self, start: &BytesStart<'_>) -> Result<()>
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.
sourcepub fn pop(&mut self)
pub fn pop(&mut self)
Ends a top-most scope by popping all namespace binding, that was added by
last call to Self::push()
.
sourcepub fn resolve<'n>(
&self,
name: QName<'n>,
use_default: bool,
) -> (ResolveResult<'_>, LocalName<'n>)
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
sourcepub fn find(&self, element_name: QName<'_>) -> ResolveResult<'_>
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=""
fn resolve_prefix( &self, prefix: Option<Prefix<'_>>, use_default: bool, ) -> ResolveResult<'_>
fn maybe_unknown(prefix: Option<Prefix<'_>>) -> ResolveResult<'static>
pub const fn iter(&self) -> PrefixIter<'_> ⓘ
Trait Implementations§
source§impl Clone for NamespaceResolver
impl Clone for NamespaceResolver
source§fn clone(&self) -> NamespaceResolver
fn clone(&self) -> NamespaceResolver
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for NamespaceResolver
impl Debug for NamespaceResolver
Auto Trait Implementations§
impl Freeze for NamespaceResolver
impl RefUnwindSafe for NamespaceResolver
impl Send for NamespaceResolver
impl Sync for NamespaceResolver
impl Unpin for NamespaceResolver
impl UnwindSafe for NamespaceResolver
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)