Skip to main content

DomStringMap

Struct DomStringMap 

Source
pub struct DomStringMap<'a, Ext: 'static> { /* private fields */ }
Expand description

Read-side view of el.dataset. Borrows the element via NodeRef; lookup converts a camelCase key to a data-* attribute name on the fly.

Implementations§

Source§

impl<'a, Ext: 'static> DomStringMap<'a, Ext>

Source

pub fn new(node: NodeRef<'a, Ext>) -> Self

Construct from a borrowed NodeRef. Used by the NodeRef::dataset() integration (M4b step 19) and tests.

Source

pub fn get(&self, key: &str) -> Option<&'a str>

Read the data-* attribute corresponding to key. Returns None when no such attribute is set. DOM el.dataset[key].

Source

pub fn contains_key(&self, key: &str) -> bool

true iff a data-* attribute corresponding to key exists on the element. DOM key in el.dataset.

Source

pub fn iter(&self) -> impl Iterator<Item = (String, &'a str)> + 'a

Iterate (key, value) pairs over every data-* attribute that round-trips through the camelCase ↔ kebab-case rule. Attributes like data-Foo (uppercase) or data- (empty key) are skipped because they aren’t valid HTML data attributes and don’t have a JS-side key.

Source

pub fn len(&self) -> usize

Count of valid data-* attributes (entries that would appear in Self::iter).

Source

pub fn is_empty(&self) -> bool

true iff Self::len is zero.

Auto Trait Implementations§

§

impl<'a, Ext> !RefUnwindSafe for DomStringMap<'a, Ext>

§

impl<'a, Ext> !Send for DomStringMap<'a, Ext>

§

impl<'a, Ext> !Sync for DomStringMap<'a, Ext>

§

impl<'a, Ext> !UnwindSafe for DomStringMap<'a, Ext>

§

impl<'a, Ext> Freeze for DomStringMap<'a, Ext>
where NodeRef<'a, Ext>: Freeze,

§

impl<'a, Ext> Unpin for DomStringMap<'a, Ext>
where NodeRef<'a, Ext>: Unpin,

§

impl<'a, Ext> UnsafeUnpin for DomStringMap<'a, Ext>
where NodeRef<'a, Ext>: UnsafeUnpin,

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>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.