pub trait ThreadSafeTryCacheStore<'lock>where
    Self: 'lock,{
    type Key;
    type Value;
    type SLock<'guard>: From<&'guard Self::XLock>
       where 'lock: 'guard;
    type XLock: 'lock;
    type Error;
    // Required methods
    fn ts_try_get(
        &'lock self,
        handle: &Self::SLock<'_>,
    ) -> Result<Option<Self::Value>, Self::Error>;
    fn ts_try_set(
        &'lock self,
        handle: &mut Self::XLock,
        value: &Self::Value,
    ) -> Result<(), Self::Error>;
    fn ts_try_xlock(
        &'lock self,
        key: &'lock Self::Key,
    ) -> Result<Self::XLock, Self::Error>;
    fn ts_try_slock(
        &'lock self,
        key: &'lock Self::Key,
    ) -> Result<Self::SLock<'lock>, Self::Error>;
    fn ts_try_xlock_nblock(
        &'lock self,
        key: &'lock Self::Key,
    ) -> Result<Self::XLock, Self::Error>;
    fn ts_try_slock_nblock(
        &'lock self,
        key: &'lock Self::Key,
    ) -> Result<Self::SLock<'lock>, Self::Error>;
    // Provided methods
    fn ts_try_exists(
        &'lock self,
        handle: &Self::SLock<'_>,
    ) -> Result<bool, Self::Error> { ... }
    fn ts_one_try_get(
        &'lock self,
        key: &'lock Self::Key,
    ) -> Result<Option<Self::Value>, Self::Error> { ... }
    fn ts_one_try_set(
        &'lock self,
        key: &'lock Self::Key,
        value: &Self::Value,
    ) -> Result<(), Self::Error> { ... }
    fn ts_one_try_exists(
        &'lock self,
        key: &'lock Self::Key,
    ) -> Result<bool, Self::Error> { ... }
}Expand description
Trait for a thread safe fallible cache store, analogous to []
Required Associated Types§
type Key
type Value
Sourcetype SLock<'guard>: From<&'guard Self::XLock>
where
    'lock: 'guard
 
type SLock<'guard>: From<&'guard Self::XLock> where 'lock: 'guard
Shared lock over a key, must be possible to make one by borrowing a exclusive lock.
type Error
Required Methods§
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Provided Methods§
Sourcefn 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.
Sourcefn 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 lock
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.
Implementors§
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
type SLock<'guard> = <S as ThreadSafeTryCacheStore<'lock>>::SLock<'guard> where 'lock: 'guard
type XLock = <S as ThreadSafeTryCacheStore<'lock>>::XLock
type Error = <S as ThreadSafeTryCacheStore<'lock>>::Error
Source§impl<'lock, K, V, E, S> ThreadSafeTryCacheStore<'lock> for DumbTryThreadSafeWrapper<'lock, K, V, E, S>where
    Self: 'lock,
    S: TryCacheStore<Key = K, Value = V, Error = E> + 'lock,
    E: From<PoisonError<RwLockReadGuard<'lock, S>>> + From<PoisonError<RwLockWriteGuard<'lock, S>>> + From<TryLockError<RwLockReadGuard<'lock, S>>> + From<TryLockError<RwLockWriteGuard<'lock, S>>>,
 
impl<'lock, K, V, E, S> ThreadSafeTryCacheStore<'lock> for DumbTryThreadSafeWrapper<'lock, K, V, E, S>where
    Self: 'lock,
    S: TryCacheStore<Key = K, Value = V, Error = E> + 'lock,
    E: From<PoisonError<RwLockReadGuard<'lock, S>>> + From<PoisonError<RwLockWriteGuard<'lock, S>>> + From<TryLockError<RwLockReadGuard<'lock, S>>> + From<TryLockError<RwLockWriteGuard<'lock, S>>>,
type Key = K
type Value = V
type SLock<'guard> = RwLockAnyGuardKey<'lock, 'guard, S, <DumbTryThreadSafeWrapper<'lock, K, V, E, S> as ThreadSafeTryCacheStore<'lock>>::Key> where 'lock: 'guard
type XLock = (RwLockWriteGuard<'lock, S>, &'lock <DumbTryThreadSafeWrapper<'lock, K, V, E, S> as ThreadSafeTryCacheStore<'lock>>::Key)
type Error = E
Source§impl<'lock, K, V, SL: for<'b> From<&'b XL> + 'lock, XL: 'lock, T: ThreadSafeCacheStore<'lock, Key = K, Value = V, SLock<'lock> = SL, XLock = XL>> ThreadSafeTryCacheStore<'lock> for T
 
impl<'lock, K, V, SL: for<'b> From<&'b XL> + 'lock, XL: 'lock, T: ThreadSafeCacheStore<'lock, Key = K, Value = V, SLock<'lock> = SL, XLock = XL>> ThreadSafeTryCacheStore<'lock> for T
Blanket implementation to allow a ThreadSafeCacheStore to behave as a
ThreadSafeTryCacheStore