Struct xml::namespace::Namespace

source ·
pub struct Namespace(pub BTreeMap<String, String>);
Expand description

Namespace is a map from prefixes to namespace URIs.

No prefix (i.e. default namespace) is designated by NS_NO_PREFIX constant.

Tuple Fields§

§0: BTreeMap<String, String>

Implementations§

source§

impl Namespace

source

pub fn empty() -> Namespace

Returns an empty namespace.

source

pub fn is_empty(&self) -> bool

Checks whether this namespace is empty.

source

pub fn is_essentially_empty(&self) -> bool

Checks whether this namespace is essentially empty, that is, it does not contain anything but default mappings.

source

pub fn contains<P: ?Sized + AsRef<str>>(&self, prefix: &P) -> bool

Checks whether this namespace mapping contains the given prefix.

Parameters
  • prefix — namespace prefix.
Return value

true if this namespace contains the given prefix, false otherwise.

source

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

Puts a mapping into this namespace.

This method does not override any already existing mappings.

Returns a boolean flag indicating whether the map already contained the given prefix.

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 force_put<P, U>(&mut self, prefix: P, uri: U) -> Option<String>where P: Into<String>, U: Into<String>,

Puts a mapping into this namespace forcefully.

This method, unlike put(), does replace an already existing mapping.

Returns previous URI which was assigned to the given prefix, if it is present.

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

Some(uri) with uri being a previous URI assigned to the prefix, or None if such prefix was not present in the namespace before.

source

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

Queries the namespace for the given prefix.

Parameters
  • prefix — namespace prefix.
Return value

Namespace URI corresponding to the given prefix, if it is present.

Trait Implementations§

source§

impl Clone for Namespace

source§

fn clone(&self) -> Namespace

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 Namespace

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 Namespace

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 Namespace

§

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

The type of the elements being iterated over.
§

type IntoIter = Map<Iter<'a, String, String>, fn(_: (&'b String, &'b String)) -> (&'b str, &'b str)>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl PartialEq<Namespace> for Namespace

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Namespace

source§

impl StructuralEq for Namespace

source§

impl StructuralPartialEq for Namespace

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.