Struct xml::namespace::Namespace [] [src]

pub struct Namespace(pub BTreeMap<String, String>);

Namespace is a map from prefixes to namespace URIs.

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

Methods

impl Namespace

fn empty() -> Namespace

Returns an empty namespace.

fn is_empty(&self) -> bool

Checks whether this namespace is empty.

fn is_essentially_empty(&self) -> bool

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

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.

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.

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.

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

impl<'a> IntoIterator for &'a Namespace

type Item = UriMapping<'a>

type IntoIter = NamespaceMappings<'a>

fn into_iter(self) -> Self::IntoIter

impl<'a> Extend<UriMapping<'a>> for Namespace

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

Derived Implementations

impl Debug for Namespace

fn fmt(&self, __arg_0: &mut Formatter) -> Result

impl Clone for Namespace

fn clone(&self) -> Namespace

1.0.0fn clone_from(&mut self, source: &Self)

impl Eq for Namespace

impl PartialEq for Namespace

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

fn ne(&self, __arg_0: &Namespace) -> bool