Trait script::dom::bindings::like::Maplike

source ·
pub 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§

source§

impl Maplike for TestBindingMaplike

§

type Key = DOMString

§

type Value = i32

source§

impl<K, V> Maplike for DomRefCell<IndexMap<K, V>>where K: ToJSValConvertible + Eq + PartialEq + Hash + Clone, V: ToJSValConvertible + Clone,

§

type Key = K

§

type Value = V

source§

impl<T: Setlike> Maplike for T

§

type Key = <T as Setlike>::Key

§

type Value = <T as Setlike>::Key