Trait foyer_storage::StorageExt

source ·
pub trait StorageExt<K, V>: Storage<K, V>
where K: StorageKey, V: StorageValue,
{ // Provided methods fn insert<AK, AV>( &self, key: AK, value: AV ) -> impl Future<Output = Result<Option<CachedEntry<K, V>>>> + Send where AK: Into<Arc<K>> + Send + 'static, AV: Into<Arc<V>> + Send + 'static { ... } fn insert_if_not_exists<AK, AV>( &self, key: AK, value: AV ) -> impl Future<Output = Result<bool>> + Send where AK: Into<Arc<K>> + Send + 'static, AV: Into<Arc<V>> + Send + 'static { ... } fn insert_with<AK, AV, F>( &self, key: AK, f: F ) -> impl Future<Output = Result<Option<CachedEntry<K, V>>>> + Send where AK: Into<Arc<K>> + Send + 'static, AV: Into<Arc<V>> + Send + 'static, F: FnOnce() -> Result<AV> + Send { ... } fn insert_with_future<AV, AK, F, FU>( &self, key: AK, f: F ) -> impl Future<Output = Result<Option<CachedEntry<K, V>>>> + Send where AK: Into<Arc<K>> + Send + 'static, AV: Into<Arc<V>> + Send + 'static, F: FnOnce() -> FU + Send, FU: FetchValueFuture<AV> { ... } fn insert_if_not_exists_with<AV, AK, F>( &self, key: AK, f: F ) -> impl Future<Output = Result<bool>> + Send where AK: Into<Arc<K>> + Send + 'static, AV: Into<Arc<V>> + Send + 'static, F: FnOnce() -> Result<AV> + Send { ... } fn insert_if_not_exists_with_future<AK, AV, F, FU>( &self, key: AK, f: F ) -> impl Future<Output = Result<bool>> + Send where AK: Into<Arc<K>> + Send + 'static, AV: Into<Arc<V>> + Send + 'static, F: FnOnce() -> FU + Send, FU: FetchValueFuture<AV> { ... } }

Provided Methods§

source

fn insert<AK, AV>( &self, key: AK, value: AV ) -> impl Future<Output = Result<Option<CachedEntry<K, V>>>> + Send
where AK: Into<Arc<K>> + Send + 'static, AV: Into<Arc<V>> + Send + 'static,

source

fn insert_if_not_exists<AK, AV>( &self, key: AK, value: AV ) -> impl Future<Output = Result<bool>> + Send
where AK: Into<Arc<K>> + Send + 'static, AV: Into<Arc<V>> + Send + 'static,

source

fn insert_with<AK, AV, F>( &self, key: AK, f: F ) -> impl Future<Output = Result<Option<CachedEntry<K, V>>>> + Send
where AK: Into<Arc<K>> + Send + 'static, AV: Into<Arc<V>> + Send + 'static, F: FnOnce() -> Result<AV> + Send,

First judge if the entry will be admitted with key and weight by admission policies. Then f will be called and entry will be inserted.

§Safety

weight MUST be equal to key.serialized_len() + value.serialized_len()

source

fn insert_with_future<AV, AK, F, FU>( &self, key: AK, f: F ) -> impl Future<Output = Result<Option<CachedEntry<K, V>>>> + Send
where AK: Into<Arc<K>> + Send + 'static, AV: Into<Arc<V>> + Send + 'static, F: FnOnce() -> FU + Send, FU: FetchValueFuture<AV>,

First judge if the entry will be admitted with key and weight by admission policies. Then f will be called to fetch value, and entry will be inserted.

source

fn insert_if_not_exists_with<AV, AK, F>( &self, key: AK, f: F ) -> impl Future<Output = Result<bool>> + Send
where AK: Into<Arc<K>> + Send + 'static, AV: Into<Arc<V>> + Send + 'static, F: FnOnce() -> Result<AV> + Send,

source

fn insert_if_not_exists_with_future<AK, AV, F, FU>( &self, key: AK, f: F ) -> impl Future<Output = Result<bool>> + Send
where AK: Into<Arc<K>> + Send + 'static, AV: Into<Arc<V>> + Send + 'static, F: FnOnce() -> FU + Send, FU: FetchValueFuture<AV>,

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<K, V, S> StorageExt<K, V> for S
where K: StorageKey, V: StorageValue, S: Storage<K, V>,