Skip to main content

Maplike

Trait Maplike 

Source
pub trait Maplike {
    type Key: ToJSValConvertible;
    type Value: ToJSValConvertible;

    // Required methods
    fn get_index(
        &self,
        cx: &mut JSContext,
        index: u32,
    ) -> Option<(Self::Key, Self::Value)>;
    fn get(&self, cx: &mut JSContext, key: Self::Key) -> Option<Self::Value>;
    fn size(&self, cx: &mut JSContext) -> u32;
    fn set(&self, cx: &mut JSContext, key: Self::Key, value: Self::Value);
    fn has(&self, cx: &mut JSContext, key: Self::Key) -> bool;
    fn clear(&self, cx: &mut JSContext);
    fn delete(&self, cx: &mut JSContext, 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, cx: &mut JSContext, index: u32, ) -> Option<(Self::Key, Self::Value)>

Source

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

Source

fn size(&self, cx: &mut JSContext) -> u32

Source

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

Source

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

Source

fn clear(&self, cx: &mut JSContext)

Source

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

Implementors§

Source§

impl<K, V> Maplike for DomRefCell<IndexMap<K, V>>

Source§

type Key = K

Source§

type Value = V

Source§

impl<T> Maplike for T
where T: Setlike,

Source§

type Key = <T as Setlike>::Key

Source§

type Value = <T as Setlike>::Key