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
sourceimpl Namespace
impl Namespace
sourcepub fn is_essentially_empty(&self) -> bool
pub fn is_essentially_empty(&self) -> bool
Checks whether this namespace is essentially empty, that is, it does not contain anything but default mappings.
sourcepub fn contains<P: ?Sized + AsRef<str>>(&self, prefix: &P) -> bool
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.
sourcepub fn put<P, U>(&mut self, prefix: P, uri: U) -> bool where
P: Into<String>,
U: Into<String>,
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.
sourcepub fn force_put<P, U>(&mut self, prefix: P, uri: U) -> Option<String> where
P: Into<String>,
U: Into<String>,
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.
sourcepub fn get<'a, P: ?Sized + AsRef<str>>(&'a self, prefix: &P) -> Option<&'a str>
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
sourceimpl<'a> Extend<(&'a str, &'a str)> for Namespace
impl<'a> Extend<(&'a str, &'a str)> for Namespace
sourcefn extend<T>(&mut self, iterable: T) where
T: IntoIterator<Item = UriMapping<'a>>,
fn extend<T>(&mut self, iterable: T) where
T: IntoIterator<Item = UriMapping<'a>>,
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl<'a> IntoIterator for &'a Namespace
impl<'a> IntoIterator for &'a Namespace
type Item = UriMapping<'a>
type Item = UriMapping<'a>
The type of the elements being iterated over.
type IntoIter = NamespaceMappings<'a>
type IntoIter = NamespaceMappings<'a>
Which kind of iterator are we turning this into?
impl Eq for Namespace
impl StructuralEq for Namespace
impl StructuralPartialEq for Namespace
Auto Trait Implementations
impl RefUnwindSafe for Namespace
impl Send for Namespace
impl Sync for Namespace
impl Unpin for Namespace
impl UnwindSafe for Namespace
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more