NodeMap

Struct NodeMap 

Source
pub struct NodeMap<'a, K, V, A: ValueAdapter<K, V>>
where K: PartialEq + Eq + Clone + Copy, V: Clone,
{ /* private fields */ }
Expand description

A NodeMap is a struct with a hash-map like API and is used to expose attribute and namespace prefix information.

You obtain one through the APIs Xot::attributes and Xot::namespaces.

Implementations§

Source§

impl<'a, K, V, A: ValueAdapter<K, V>> NodeMap<'a, K, V, A>
where K: PartialEq + Eq + Clone + Copy + Hash, V: Clone + 'a,

Source

pub fn get_node(&self, key: impl Into<K> + Copy) -> Option<Node>

Get the node representing the value in the map.

This is an attribute or namespace node. This node has the element node as a parent, even though it’s not in xot.children(parent).

Source

pub fn len(&self) -> usize

Returns the number of entries in the map, also referred to as its ‘length’.

Source

pub fn is_empty(&self) -> bool

Returns true if the map contains no entries.

Source

pub fn contains_key(&self, key: impl Into<K> + Copy) -> bool

Return true if an equivalent to key exists in the map.

Source

pub fn get(&self, key: impl Into<K> + Copy) -> Option<&'a V>

Return a reference to the value stored for key, if it is present, else None.

Source

pub fn iter(&self) -> impl Iterator<Item = (K, &'a V)> + '_

An iterator visiting all key-value pairs in insertion order. The iterator element type is (&'a K, &'a V).

Source

pub fn to_vec(&self) -> Vec<(K, V)>

Copies the map entries into a new Vec<(K, V)>.

Source

pub fn keys(&self) -> impl Iterator<Item = K> + '_

An iterator visiting all keys in insertion order. The iterator element type is &'a K.

Source

pub fn values(&self) -> impl Iterator<Item = &'a V> + '_

An iterator visiting all values in insertion order. The iterator element type is &'a V.

Source

pub fn nodes(&self) -> impl Iterator<Item = Node> + '_

An iterator visiting all the nodes in insertion order.

Source

pub fn to_hashmap(&self) -> AHashMap<K, V>

Convert into a hashmap

Trait Implementations§

Source§

impl<'a, K, V, A: Debug + ValueAdapter<K, V>> Debug for NodeMap<'a, K, V, A>
where K: PartialEq + Eq + Clone + Copy + Debug, V: Clone + Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, K, V, A> Freeze for NodeMap<'a, K, V, A>

§

impl<'a, K, V, A> RefUnwindSafe for NodeMap<'a, K, V, A>

§

impl<'a, K, V, A> Send for NodeMap<'a, K, V, A>
where K: Send, V: Send, A: Send,

§

impl<'a, K, V, A> Sync for NodeMap<'a, K, V, A>
where K: Sync, V: Sync, A: Sync,

§

impl<'a, K, V, A> Unpin for NodeMap<'a, K, V, A>
where K: Unpin, V: Unpin, A: Unpin,

§

impl<'a, K, V, A> UnwindSafe for NodeMap<'a, K, V, A>
where K: UnwindSafe, V: UnwindSafe, A: UnwindSafe,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T