pub trait Map<'a, K, V>{
type Error: Error;
type Iterator: Iterator<Item = (K, V)>;
type SafeIterator: Iterator<Item = Result<(K, V), TypedStoreError>>;
type Keys: Iterator<Item = Result<K, TypedStoreError>>;
type Values: Iterator<Item = Result<V, TypedStoreError>>;
Show 24 methods
// Required 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 unsafe_clear(&self) -> Result<(), Self::Error>;
fn delete_file_in_range(
&self,
from: &K,
to: &K,
) -> Result<(), TypedStoreError>;
fn schedule_delete_all(&self) -> Result<(), TypedStoreError>;
fn is_empty(&self) -> bool;
fn unbounded_iter(&'a self) -> Self::Iterator;
fn iter_with_bounds(
&'a self,
lower_bound: Option<K>,
upper_bound: Option<K>,
) -> Self::Iterator;
fn range_iter(&'a self, range: impl RangeBounds<K>) -> Self::Iterator;
fn safe_iter(&'a self) -> Self::SafeIterator;
fn safe_iter_with_bounds(
&'a self,
lower_bound: Option<K>,
upper_bound: Option<K>,
) -> Self::SafeIterator;
fn safe_range_iter(
&'a self,
range: impl RangeBounds<K>,
) -> Self::SafeIterator;
fn keys(&'a self) -> Self::Keys;
fn values(&'a self) -> Self::Values;
fn try_catch_up_with_primary(&self) -> Result<(), Self::Error>;
// Provided methods
fn multi_contains_keys<J>(
&self,
keys: impl IntoIterator<Item = J>,
) -> Result<Vec<bool>, 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> { ... }
fn multi_get_raw_bytes<J>(
&self,
keys: impl IntoIterator<Item = J>,
) -> Result<Vec<Option<Vec<u8>>>, Self::Error>
where J: Borrow<K> { ... }
fn chunked_multi_get<J>(
&self,
keys: impl IntoIterator<Item = J>,
_chunk_size: usize,
) -> 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 SafeIterator: Iterator<Item = Result<(K, V), TypedStoreError>>
type Keys: Iterator<Item = Result<K, TypedStoreError>>
type Values: Iterator<Item = Result<V, TypedStoreError>>
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 (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 unsafe_clear(&self) -> Result<(), Self::Error>
fn unsafe_clear(&self) -> Result<(), Self::Error>
Removes every key-value pair from the map.
Sourcefn delete_file_in_range(&self, from: &K, to: &K) -> Result<(), TypedStoreError>
fn delete_file_in_range(&self, from: &K, to: &K) -> Result<(), TypedStoreError>
Removes every key-value pair from the map by deleting the underlying file.
Sourcefn schedule_delete_all(&self) -> Result<(), TypedStoreError>
fn schedule_delete_all(&self) -> Result<(), TypedStoreError>
Uses delete range on the entire key range
Sourcefn unbounded_iter(&'a self) -> Self::Iterator
fn unbounded_iter(&'a self) -> Self::Iterator
Returns an unbounded iterator visiting each key-value pair in the map. This is potentially unsafe as it can perform a full table scan
Sourcefn iter_with_bounds(
&'a self,
lower_bound: Option<K>,
upper_bound: Option<K>,
) -> Self::Iterator
fn iter_with_bounds( &'a self, lower_bound: Option<K>, upper_bound: Option<K>, ) -> Self::Iterator
Returns an iterator visiting each key-value pair within the specified bounds in the map.
Sourcefn range_iter(&'a self, range: impl RangeBounds<K>) -> Self::Iterator
fn range_iter(&'a self, range: impl RangeBounds<K>) -> Self::Iterator
Similar to iter_with_bounds
but allows specifying
inclusivity/exclusivity of ranges explicitly. TODO: find better name
Sourcefn safe_iter(&'a self) -> Self::SafeIterator
fn safe_iter(&'a self) -> Self::SafeIterator
Same as iter
but performs status check.
fn safe_iter_with_bounds( &'a self, lower_bound: Option<K>, upper_bound: Option<K>, ) -> Self::SafeIterator
fn safe_range_iter(&'a self, range: impl RangeBounds<K>) -> Self::SafeIterator
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 multi_contains_keys<J>(
&self,
keys: impl IntoIterator<Item = J>,
) -> Result<Vec<bool>, Self::Error>where
J: Borrow<K>,
fn multi_contains_keys<J>(
&self,
keys: impl IntoIterator<Item = J>,
) -> Result<Vec<bool>, Self::Error>where
J: Borrow<K>,
Returns true if the map contains a value for the specified key.
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_get_raw_bytes<J>(
&self,
keys: impl IntoIterator<Item = J>,
) -> Result<Vec<Option<Vec<u8>>>, Self::Error>where
J: Borrow<K>,
fn multi_get_raw_bytes<J>(
&self,
keys: impl IntoIterator<Item = J>,
) -> Result<Vec<Option<Vec<u8>>>, Self::Error>where
J: Borrow<K>,
Returns a vector of raw values corresponding to the keys provided, non-atomically.
Sourcefn chunked_multi_get<J>(
&self,
keys: impl IntoIterator<Item = J>,
_chunk_size: usize,
) -> Result<Vec<Option<V>>, Self::Error>where
J: Borrow<K>,
fn chunked_multi_get<J>(
&self,
keys: impl IntoIterator<Item = J>,
_chunk_size: usize,
) -> 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>
fn multi_insert<J, U>( &self, key_val_pairs: impl IntoIterator<Item = (J, U)>, ) -> Result<(), Self::Error>
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.
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.