pub struct ThreadSafeGenTryCacheStoreWrapper<'lock, K, V, E, A, StErr: Into<E> + 'lock, FnErr: Into<E> + 'lock, S: ThreadSafeTryCacheStore<'lock, Key = K, Value = V, Error = StErr>, F: Fn(&K, A) -> Result<V, FnErr> + 'lock> {
    pub store: S,
    pub generator: F,
    /* private fields */
}Expand description
Fallible thread safe generative cache store wrapper around a ThreadSafeTryCacheStore
and a generator function.
Generics:
- K: Type of the key used for cache indexing.
- V: Type of the value stored in the cache store.
- E: Error type.
- A: Type of additional arguments of the generator function.
- StErr: Error type of the store.
- FnErr: Error type of the function.
- S:- ThreadSafeCacheStorewhich this wraps around.
- F:- Fn<&K, A>with- Vreturn generator function.
Fields§
§store: S§generator: FImplementations§
Source§impl<'lock, K, V, E, A, StErr: Into<E> + 'lock, FnErr: Into<E> + 'lock, S: ThreadSafeTryCacheStore<'lock, Key = K, Value = V, Error = StErr>, F: Fn(&K, A) -> Result<V, FnErr>> ThreadSafeGenTryCacheStoreWrapper<'lock, K, V, E, A, StErr, FnErr, S, F>
 
impl<'lock, K, V, E, A, StErr: Into<E> + 'lock, FnErr: Into<E> + 'lock, S: ThreadSafeTryCacheStore<'lock, Key = K, Value = V, Error = StErr>, F: Fn(&K, A) -> Result<V, FnErr>> ThreadSafeGenTryCacheStoreWrapper<'lock, K, V, E, A, StErr, FnErr, S, F>
Default implementation
Sourcepub fn new(store: S, generator: F) -> Self
 
pub fn new(store: S, generator: F) -> Self
Make a new ThreadSafeGenCacheStoreWrapper from a ThreadSafeCacheStore and a generator function.
Trait Implementations§
Source§impl<'lock, K, V, E, A, StErr: Into<E> + 'lock, FnErr: Into<E> + 'lock, S, F: Fn(&K, A) -> Result<V, FnErr> + 'lock> ThreadSafeTryCacheStore<'lock> for ThreadSafeGenTryCacheStoreWrapper<'lock, K, V, E, A, StErr, FnErr, S, F>where
    S: ThreadSafeTryCacheStore<'lock> + ThreadSafeTryCacheStore<'lock, Key = K, Value = V, Error = StErr>,
 
impl<'lock, K, V, E, A, StErr: Into<E> + 'lock, FnErr: Into<E> + 'lock, S, F: Fn(&K, A) -> Result<V, FnErr> + 'lock> ThreadSafeTryCacheStore<'lock> for ThreadSafeGenTryCacheStoreWrapper<'lock, K, V, E, A, StErr, FnErr, S, F>where
    S: ThreadSafeTryCacheStore<'lock> + ThreadSafeTryCacheStore<'lock, Key = K, Value = V, Error = StErr>,
type Key = <S as ThreadSafeTryCacheStore<'lock>>::Key
type Value = <S as ThreadSafeTryCacheStore<'lock>>::Value
Source§type SLock<'guard> = <S as ThreadSafeTryCacheStore<'lock>>::SLock<'guard>
where
    'lock: 'guard
 
type SLock<'guard> = <S as ThreadSafeTryCacheStore<'lock>>::SLock<'guard> where 'lock: 'guard
Shared lock over a key, must be possible to make one by borrowing a exclusive lock.
Source§type XLock = <S as ThreadSafeTryCacheStore<'lock>>::XLock
 
type XLock = <S as ThreadSafeTryCacheStore<'lock>>::XLock
Exclusive lock over a wey.
type Error = <S as ThreadSafeTryCacheStore<'lock>>::Error
Source§fn ts_try_get(
    &'lock self,
    handle: &Self::SLock<'_>,
) -> Result<Option<Self::Value>, Self::Error>
 
fn ts_try_get( &'lock self, handle: &Self::SLock<'_>, ) -> Result<Option<Self::Value>, Self::Error>
Attempts to return an option of the owned cache element if present.
Source§fn ts_try_set(
    &'lock self,
    handle: &mut Self::XLock,
    value: &Self::Value,
) -> Result<(), Self::Error>
 
fn ts_try_set( &'lock self, handle: &mut Self::XLock, value: &Self::Value, ) -> Result<(), Self::Error>
Attempts to set a value given its key.
Source§fn ts_try_exists(
    &'lock self,
    handle: &Self::SLock<'_>,
) -> Result<bool, Self::Error>
 
fn ts_try_exists( &'lock self, handle: &Self::SLock<'_>, ) -> Result<bool, Self::Error>
Attempts to check if the cache key entry exists.
Source§fn ts_one_try_get(
    &'lock self,
    key: &'lock Self::Key,
) -> Result<Option<Self::Value>, Self::Error>
 
fn ts_one_try_get( &'lock self, key: &'lock Self::Key, ) -> Result<Option<Self::Value>, Self::Error>
Same as 
ts_get but it performs a one-time lockSource§fn ts_one_try_set(
    &'lock self,
    key: &'lock Self::Key,
    value: &Self::Value,
) -> Result<(), Self::Error>
 
fn ts_one_try_set( &'lock self, key: &'lock Self::Key, value: &Self::Value, ) -> Result<(), Self::Error>
Same as 
ts_set but it performs a one-time lockSource§fn ts_one_try_exists(
    &'lock self,
    key: &'lock Self::Key,
) -> Result<bool, Self::Error>
 
fn ts_one_try_exists( &'lock self, key: &'lock Self::Key, ) -> Result<bool, Self::Error>
Same as 
ts_exists but it performs a one-time lockSource§fn ts_try_xlock(
    &'lock self,
    key: &'lock Self::Key,
) -> Result<Self::XLock, Self::Error>
 
fn ts_try_xlock( &'lock self, key: &'lock Self::Key, ) -> Result<Self::XLock, Self::Error>
Attempt to exclusively lock a key until the handle is dropped.
Source§fn ts_try_slock(
    &'lock self,
    key: &'lock Self::Key,
) -> Result<Self::SLock<'lock>, Self::Error>
 
fn ts_try_slock( &'lock self, key: &'lock Self::Key, ) -> Result<Self::SLock<'lock>, Self::Error>
Attempt to acquire a shared lock of a key until the handle is dropped.
Source§impl<'lock, K, V: Clone, E, A, StErr: Into<E> + 'lock, FnErr: Into<E> + 'lock, S: ThreadSafeTryCacheStore<'lock, Key = K, Value = V, Error = StErr>, F: Fn(&K, A) -> Result<V, FnErr>> ThreadSafeTryGenCacheStore<'lock> for ThreadSafeGenTryCacheStoreWrapper<'lock, K, V, E, A, StErr, FnErr, S, F>
 
impl<'lock, K, V: Clone, E, A, StErr: Into<E> + 'lock, FnErr: Into<E> + 'lock, S: ThreadSafeTryCacheStore<'lock, Key = K, Value = V, Error = StErr>, F: Fn(&K, A) -> Result<V, FnErr>> ThreadSafeTryGenCacheStore<'lock> for ThreadSafeGenTryCacheStoreWrapper<'lock, K, V, E, A, StErr, FnErr, S, F>
Implement ThreadSafeCacheStore
type Key = K
type Value = V
type Args = A
type Error = E
Source§fn ts_try_gen(
    &self,
    key: &<Self as ThreadSafeTryGenCacheStore<'lock>>::Key,
    args: Self::Args,
) -> Result<<Self as ThreadSafeTryGenCacheStore<'lock>>::Value, <Self as ThreadSafeTryGenCacheStore<'lock>>::Error>
 
fn ts_try_gen( &self, key: &<Self as ThreadSafeTryGenCacheStore<'lock>>::Key, args: Self::Args, ) -> Result<<Self as ThreadSafeTryGenCacheStore<'lock>>::Value, <Self as ThreadSafeTryGenCacheStore<'lock>>::Error>
Generate a new value without checking cache or adding the value to it.
Source§fn ts_try_get_or_gen(
    &'lock self,
    key: &'lock <Self as ThreadSafeTryGenCacheStore<'lock>>::Key,
    args: Self::Args,
) -> Result<<Self as ThreadSafeTryGenCacheStore<'lock>>::Value, <Self as ThreadSafeTryGenCacheStore<'lock>>::Error>
 
fn ts_try_get_or_gen( &'lock self, key: &'lock <Self as ThreadSafeTryGenCacheStore<'lock>>::Key, args: Self::Args, ) -> Result<<Self as ThreadSafeTryGenCacheStore<'lock>>::Value, <Self as ThreadSafeTryGenCacheStore<'lock>>::Error>
Get the value from cache or generate a new one without adding it.
Source§fn ts_try_get_or_new(
    &'lock self,
    key: &'lock <Self as ThreadSafeTryGenCacheStore<'lock>>::Key,
    args: Self::Args,
) -> Result<<Self as ThreadSafeTryGenCacheStore<'lock>>::Value, <Self as ThreadSafeTryGenCacheStore<'lock>>::Error>
 
fn ts_try_get_or_new( &'lock self, key: &'lock <Self as ThreadSafeTryGenCacheStore<'lock>>::Key, args: Self::Args, ) -> Result<<Self as ThreadSafeTryGenCacheStore<'lock>>::Value, <Self as ThreadSafeTryGenCacheStore<'lock>>::Error>
Get the value from cache or generate a new one adding it.
Source§fn ts_try_gen_new(
    &'lock self,
    key: &'lock <Self as ThreadSafeTryGenCacheStore<'lock>>::Key,
    args: Self::Args,
) -> Result<<Self as ThreadSafeTryGenCacheStore<'lock>>::Value, <Self as ThreadSafeTryGenCacheStore<'lock>>::Error>
 
fn ts_try_gen_new( &'lock self, key: &'lock <Self as ThreadSafeTryGenCacheStore<'lock>>::Key, args: Self::Args, ) -> Result<<Self as ThreadSafeTryGenCacheStore<'lock>>::Value, <Self as ThreadSafeTryGenCacheStore<'lock>>::Error>
Generate a new value without checking cache and add the value to it, possibly overwriting
previous values.
Auto Trait Implementations§
impl<'lock, K, V, E, A, StErr, FnErr, S, F> Freeze for ThreadSafeGenTryCacheStoreWrapper<'lock, K, V, E, A, StErr, FnErr, S, F>
impl<'lock, K, V, E, A, StErr, FnErr, S, F> RefUnwindSafe for ThreadSafeGenTryCacheStoreWrapper<'lock, K, V, E, A, StErr, FnErr, S, F>where
    S: RefUnwindSafe,
    F: RefUnwindSafe,
    K: RefUnwindSafe,
    V: RefUnwindSafe,
    A: RefUnwindSafe,
    E: RefUnwindSafe,
impl<'lock, K, V, E, A, StErr, FnErr, S, F> Send for ThreadSafeGenTryCacheStoreWrapper<'lock, K, V, E, A, StErr, FnErr, S, F>
impl<'lock, K, V, E, A, StErr, FnErr, S, F> Sync for ThreadSafeGenTryCacheStoreWrapper<'lock, K, V, E, A, StErr, FnErr, S, F>
impl<'lock, K, V, E, A, StErr, FnErr, S, F> Unpin for ThreadSafeGenTryCacheStoreWrapper<'lock, K, V, E, A, StErr, FnErr, S, F>
impl<'lock, K, V, E, A, StErr, FnErr, S, F> UnwindSafe for ThreadSafeGenTryCacheStoreWrapper<'lock, K, V, E, A, StErr, FnErr, S, F>where
    S: UnwindSafe,
    F: UnwindSafe,
    K: RefUnwindSafe,
    V: RefUnwindSafe,
    A: RefUnwindSafe,
    E: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more