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

pub struct Namespace(pub HashMap<Option<String>, String>);

Namespace is a map from prefixes to namespace URIs.

None prefix means no prefix (i.e. default namespace).

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 the default mappings.

fn put<'s1, 's2, S1, S2>(&mut self, prefix: Option<S1>, uri: S2) -> bool where S1: Into<Cow<'s1, str>>, S2: Into<Cow<'s2, str>>

Puts a mapping into this namespace.

This method does not override an already existing mapping.

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

Parameters

  • prefix --- namespace prefix (None means default namespace);
  • 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<'s1, 's2, S1, S2>(&mut self, prefix: Option<S1>, uri: S2) -> Option<String> where S1: Into<Cow<'s1, str>>, S2: Into<Cow<'s2, str>>

Puts a mapping into this namespace forcefully.

This method, as opposed to 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 (None means default namespace);
  • 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>(&'a self, prefix: &Option<String>) -> Option<&'a str>

Queries the namespace for the given prefix.

Parameters

  • prefix --- namespace prefix (None means default namespace).

Return value

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

Trait Implementations

impl<'a> NamespaceIterable<'a> for Namespace

type Iter = NamespaceMappings<'a>

fn uri_mappings(&'a self) -> NamespaceMappings<'a>

Derived Implementations

impl Clone for Namespace

fn clone(&self) -> Namespace

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

impl PartialEq for Namespace

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

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