script::dom::bindings::import::module

Trait Maplike

Source
pub(crate) trait Maplike {
    type Key: ToJSValConvertible;
    type Value: ToJSValConvertible;

    // Required methods
    fn get_index(&self, index: u32) -> Option<(Self::Key, Self::Value)>;
    fn get(&self, key: Self::Key) -> Option<Self::Value>;
    fn size(&self) -> u32;
    fn set(&self, key: Self::Key, value: Self::Value);
    fn has(&self, key: Self::Key) -> bool;
    fn clear(&self);
    fn delete(&self, key: Self::Key) -> bool;
}
Expand description

Every Maplike dom_struct must implement this to provide access to underlying storage so codegen can automatically generate all maplike methods

In case you use a type that implements Maplike as underlying storage it’s recommended to use maplike macro.

Required Associated Types§

Source

type Key: ToJSValConvertible

The type of the key of the map.

Source

type Value: ToJSValConvertible

The type of the value of the map.

Required Methods§

Source

fn get_index(&self, index: u32) -> Option<(Self::Key, Self::Value)>

Source

fn get(&self, key: Self::Key) -> Option<Self::Value>

Source

fn size(&self) -> u32

Source

fn set(&self, key: Self::Key, value: Self::Value)

Source

fn has(&self, key: Self::Key) -> bool

Source

fn clear(&self)

Source

fn delete(&self, key: Self::Key) -> bool

Implementors§