pub struct SimpleNamespaces { /* private fields */ }
Expand description

Simple namespace tracker.

 This is the default namespace tracker used by Encoder::new. At the cost of increased output size, it reduces memory footprint by only tracking unprefixed namespaces. Prefixed namespaces may be declared, but are forgotten about once the element start is over.

Effectively, when used with an Encoder, this means that prefixed namespaces will only ever be used for attributes, and may be re-declared a lot.

 One exception is that prefixed namespaces declared on the root element will actually be made available on all child elements.

Implementations§

source§

impl SimpleNamespaces

source

pub fn new() -> Self

Create a new, empty namespace tracker.

source

pub fn lookup_prefix( &self, prefix: Option<&NcNameStr> ) -> Result<NamespaceName, PrefixError>

Look up the namespace URI for a given prefix

 Note: This function is implemented as O(n) function because it should rarely, if ever, be necessary to use. Speeding up runtime of this function would increase memory cost at neglegible gain.

The namespace URIs for the xml and xmlns prefixes are always returned, even if not explicitly declared.

Trait Implementations§

source§

impl Debug for SimpleNamespaces

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl TrackNamespace for SimpleNamespaces

source§

fn declare_fixed( &mut self, prefix: Option<&NcNameStr>, name: Option<NamespaceName> ) -> bool

Declare a namespace URI with a defined prefix. Read more
source§

fn declare_auto( &mut self, name: Option<NamespaceName> ) -> (bool, Option<&NcNameStr>)

Declare a namespace URI with an auto-generated prefix or by using the default namespace. Read more
source§

fn declare_with_auto_prefix( &mut self, name: Option<NamespaceName> ) -> (bool, &NcNameStr)

Declare a namespace URI with an auto-generated prefix. Read more
source§

fn get_prefix_or_default( &self, name: Option<NamespaceName> ) -> Result<Option<&NcNameStr>, PrefixError>

Get the prefix for a given URI, which may be empty if the namespace with that URI is defined as the default namespace.
source§

fn get_prefix( &self, name: Option<NamespaceName> ) -> Result<&NcNameStr, PrefixError>

Get the prefix for a given URI. Read more
source§

fn push(&mut self)

Complete an element declaration.
source§

fn pop(&mut self)

Signal end of element to undeclare nested namespace declarations.
source§

fn new_default_declaration(&self) -> Option<Option<&NamespaceName>>

Return the newly declared default namespace, if any. Read more
source§

fn new_prefix_declarations<'x>( &'x self ) -> Box<dyn Iterator<Item = (&Option<NamespaceName>, &NcNameStr)> + 'x>

Return an iterator over the the newly declared prefixes.

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> 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, U> TryFrom<U> for T
where 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 T
where 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.