Skip to main content

Namespace

Struct 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) -> bool
where 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.

Source

pub fn borrow(&self) -> Cow<'_, Self>

Borrowed namespace for the writer

Source

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

Namespace mappings contained in a namespace.

Trait Implementations§

Source§

impl Clone for Namespace

Source§

fn clone(&self) -> Namespace

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 Eq for Namespace

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

Source§

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

The type of the elements being iterated over.
Source§

type IntoIter = Map<Iter<'a, String, String>, for<'b> 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 for Namespace

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 StructuralPartialEq for Namespace

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.