Trait typed_store::traits::Map
source · [−]pub trait Map<'a, K, V>where
K: Serialize + DeserializeOwned + ?Sized,
V: Serialize + DeserializeOwned,{
type Error: Error;
type Iterator: Iterator<Item = (K, V)>;
type Keys: Iterator<Item = K>;
type Values: Iterator<Item = V>;
Show 15 methods
fn contains_key(&self, key: &K) -> Result<bool, Self::Error>;
fn get(&self, key: &K) -> Result<Option<V>, Self::Error>;
fn get_raw_bytes(&self, key: &K) -> Result<Option<Vec<u8>>, Self::Error>;
fn insert(&self, key: &K, value: &V) -> Result<(), Self::Error>;
fn remove(&self, key: &K) -> Result<(), Self::Error>;
fn clear(&self) -> Result<(), Self::Error>;
fn is_empty(&self) -> bool;
fn iter(&'a self) -> Self::Iterator;
fn keys(&'a self) -> Self::Keys;
fn values(&'a self) -> Self::Values;
fn try_catch_up_with_primary(&self) -> Result<(), Self::Error>;
fn get_or_insert_unsafe<F: FnOnce() -> V>(
&self,
key: &K,
default: F
) -> Result<V, Self::Error> { ... }
fn multi_get<J>(
&self,
keys: impl IntoIterator<Item = J>
) -> Result<Vec<Option<V>>, Self::Error>
where
J: Borrow<K>,
{ ... }
fn multi_insert<J, U>(
&self,
key_val_pairs: impl IntoIterator<Item = (J, U)>
) -> Result<(), Self::Error>
where
J: Borrow<K>,
U: Borrow<V>,
{ ... }
fn multi_remove<J>(
&self,
keys: impl IntoIterator<Item = J>
) -> Result<(), Self::Error>
where
J: Borrow<K>,
{ ... }
}Required Associated Types
type Error: Error
type Iterator: Iterator<Item = (K, V)>
type Keys: Iterator<Item = K>
type Values: Iterator<Item = V>
Required Methods
sourcefn contains_key(&self, key: &K) -> Result<bool, Self::Error>
fn contains_key(&self, key: &K) -> Result<bool, Self::Error>
Returns true if the map contains a value for the specified key.
sourcefn get(&self, key: &K) -> Result<Option<V>, Self::Error>
fn get(&self, key: &K) -> Result<Option<V>, Self::Error>
Returns the value for the given key from the map, if it exists.
sourcefn get_raw_bytes(&self, key: &K) -> Result<Option<Vec<u8>>, Self::Error>
fn get_raw_bytes(&self, key: &K) -> Result<Option<Vec<u8>>, Self::Error>
Returns the raw value (bincode serialized bytes) for the given key from the map, if it exists.
sourcefn insert(&self, key: &K, value: &V) -> Result<(), Self::Error>
fn insert(&self, key: &K, value: &V) -> Result<(), Self::Error>
Inserts the given key-value pair into the map.
sourcefn remove(&self, key: &K) -> Result<(), Self::Error>
fn remove(&self, key: &K) -> Result<(), Self::Error>
Removes the entry for the given key from the map.
sourcefn iter(&'a self) -> Self::Iterator
fn iter(&'a self) -> Self::Iterator
Returns an iterator visiting each key-value pair in the map.
sourcefn try_catch_up_with_primary(&self) -> Result<(), Self::Error>
fn try_catch_up_with_primary(&self) -> Result<(), Self::Error>
Try to catch up with primary when running as secondary
Provided Methods
sourcefn get_or_insert_unsafe<F: FnOnce() -> V>(
&self,
key: &K,
default: F
) -> Result<V, Self::Error>
fn get_or_insert_unsafe<F: FnOnce() -> V>(
&self,
key: &K,
default: F
) -> Result<V, Self::Error>
Returns the value for the given key from the map, if it exists or the given default value if it does not. This method is not thread safe
sourcefn multi_get<J>(
&self,
keys: impl IntoIterator<Item = J>
) -> Result<Vec<Option<V>>, Self::Error>where
J: Borrow<K>,
fn multi_get<J>(
&self,
keys: impl IntoIterator<Item = J>
) -> Result<Vec<Option<V>>, Self::Error>where
J: Borrow<K>,
Returns a vector of values corresponding to the keys provided, non-atomically.
sourcefn multi_insert<J, U>(
&self,
key_val_pairs: impl IntoIterator<Item = (J, U)>
) -> Result<(), Self::Error>where
J: Borrow<K>,
U: Borrow<V>,
fn multi_insert<J, U>(
&self,
key_val_pairs: impl IntoIterator<Item = (J, U)>
) -> Result<(), Self::Error>where
J: Borrow<K>,
U: Borrow<V>,
Inserts key-value pairs, non-atomically.
sourcefn multi_remove<J>(
&self,
keys: impl IntoIterator<Item = J>
) -> Result<(), Self::Error>where
J: Borrow<K>,
fn multi_remove<J>(
&self,
keys: impl IntoIterator<Item = J>
) -> Result<(), Self::Error>where
J: Borrow<K>,
Removes keys, non-atomically.