xml::namespace

Struct NamespaceStack

Source
pub struct NamespaceStack(pub Vec<Namespace>);
Expand description

Namespace stack is a sequence of namespaces.

Namespace stack is used to represent cumulative namespace consisting of combined namespaces from nested elements.

Tuple Fields§

§0: Vec<Namespace>

Implementations§

Source§

impl NamespaceStack

Source

pub fn empty() -> Self

Returns an empty namespace stack.

Source

pub fn default() -> Self

Returns a namespace stack with default items in it.

Default items are the following:

  • xmlhttp://www.w3.org/XML/1998/namespace;
  • xmlnshttp://www.w3.org/2000/xmlns/.
Source

pub fn push_empty(&mut self) -> &mut Self

Adds an empty namespace to the top of this stack.

Source

pub fn pop(&mut self) -> Namespace

Removes the topmost namespace in this stack.

Panics if the stack is empty.

Source

pub fn try_pop(&mut self) -> Option<Namespace>

Removes the topmost namespace in this stack.

Returns Some(namespace) if this stack is not empty and None otherwise.

Source

pub fn peek_mut(&mut self) -> &mut Namespace

Borrows the topmost namespace mutably, leaving the stack intact.

Panics if the stack is empty.

Source

pub fn peek(&self) -> &Namespace

Borrows the topmost namespace immutably, leaving the stack intact.

Panics if the stack is empty.

Source

pub fn put_checked<P, U>(&mut self, prefix: P, uri: U) -> bool
where P: Into<String> + AsRef<str>, U: Into<String> + AsRef<str>,

Puts a mapping into the topmost namespace if this stack does not already contain one.

Returns a boolean flag indicating whether the insertion has completed successfully. Note that both key and value are matched and the mapping is inserted if either namespace prefix is not already mapped, or if it is mapped, but to a different URI.

§Parameters
  • prefix — namespace prefix;
  • uri — namespace URI.
§Return value

true if prefix has been inserted successfully; false if the prefix was already present in the namespace stack.

Source

pub fn put<P, U>(&mut self, prefix: P, uri: U) -> bool
where P: Into<String>, U: Into<String>,

Puts a mapping into the topmost namespace in this stack.

This method does not override a mapping in the topmost namespace if it is already present, however, it does not depend on other namespaces in the stack, so it is possible to put a mapping which is present in lower namespaces.

Returns a boolean flag indicating whether the insertion has completed successfully.

§Parameters
  • prefix — namespace prefix;
  • uri — namespace URI.
§Return value

true if prefix has been inserted successfully; false if the prefix was already present in the namespace.

Source

pub fn get<'a, P: ?Sized + AsRef<str>>(&'a self, prefix: &P) -> Option<&'a str>

Performs a search for the given prefix in the whole stack.

This method walks the stack from top to bottom, querying each namespace in order for the given prefix. If none of the namespaces contains the prefix, None is returned.

§Parameters
  • prefix — namespace prefix.
Source

pub fn squash(&self) -> Namespace

Combines this stack of namespaces into a single namespace.

Namespaces are combined in left-to-right order, that is, rightmost namespace elements take priority over leftmost ones.

Source

pub fn checked_target(&mut self) -> CheckedTarget<'_>

Returns an object which implements Extend using put_checked() instead of put().

See CheckedTarget for more information.

Source

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

Returns an iterator over all mappings in this namespace stack.

Trait Implementations§

Source§

impl Clone for NamespaceStack

Source§

fn clone(&self) -> NamespaceStack

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 NamespaceStack

Source§

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

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

impl<'a> Extend<(&'a str, &'a str)> for NamespaceStack

Source§

fn extend<T>(&mut self, iterable: T)
where T: IntoIterator<Item = UriMapping<'a>>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<'a> IntoIterator for &'a NamespaceStack

Source§

type IntoIter = NamespaceStackMappings<'a>

Which kind of iterator are we turning this into?
Source§

type Item = (&'a str, &'a str)

The type of the elements being iterated over.
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for NamespaceStack

Source§

fn eq(&self, other: &NamespaceStack) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for NamespaceStack

Source§

impl StructuralPartialEq for NamespaceStack

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.