Dictionary

Trait Dictionary 

Source
pub trait Dictionary {
    type Key: 'static;
    type Value: 'static;
    type Guard: WatcherGuard;

    // Required methods
    fn get(&self, key: &Self::Key) -> Option<Self::Value>;
    fn watch(
        &self,
        key: &Self::Key,
        watcher: impl Fn(Context<Option<Self::Value>>) + 'static,
    ) -> Self::Guard;
}
Expand description

A trait for dictionary-like data structures that support reactive watching of key-value pairs.

Required Associated Types§

Source

type Key: 'static

The type of keys in the dictionary.

Source

type Value: 'static

The type of values in the dictionary.

Source

type Guard: WatcherGuard

The type of guard returned when registering a watcher.

Required Methods§

Source

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

Gets a value from the dictionary for the specified key.

Source

fn watch( &self, key: &Self::Key, watcher: impl Fn(Context<Option<Self::Value>>) + 'static, ) -> Self::Guard

Registers a watcher for changes to the specified key in the dictionary.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<K, V> Dictionary for BTreeMap<K, V>
where K: Ord + Clone + 'static, V: Clone + 'static,

Source§

type Key = K

Source§

type Value = V

Source§

type Guard = ()

Source§

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

Source§

fn watch( &self, _key: &Self::Key, _watcher: impl Fn(Context<Option<Self::Value>>) + 'static, ) -> Self::Guard

Source§

impl<K: Hash + Eq + Clone + 'static, V: Clone + 'static, S: BuildHasher + 'static> Dictionary for HashMap<K, V, S>

Source§

type Key = K

Source§

type Value = V

Source§

type Guard = ()

Source§

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

Source§

fn watch( &self, _key: &Self::Key, _watcher: impl Fn(Context<Option<Self::Value>>) + 'static, ) -> Self::Guard

Implementors§

Source§

impl<K: Ord + Clone + 'static, V: Clone + 'static> Dictionary for Map<K, V>