Skip to main content

Lockable

Trait Lockable 

Source
pub trait Lockable<T: ?Sized>: Send + Sync {
    type Guard<'a>: DerefMut<Target = T> + 'a
       where Self: 'a;

    // Required method
    fn lock(&self) -> Result<Self::Guard<'_>, LockError>;
}

Required Associated Types§

Source

type Guard<'a>: DerefMut<Target = T> + 'a where Self: 'a

Required Methods§

Source

fn lock(&self) -> Result<Self::Guard<'_>, LockError>

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.

Implementations on Foreign Types§

Source§

impl<T: ?Sized + Send + Sync> Lockable<T> for RwLock<T>

Source§

type Guard<'a> = RwLockWriteGuard<'a, T> where Self: 'a

Source§

fn lock(&self) -> Result<Self::Guard<'_>, LockError>

Source§

impl<T: ?Sized + Send + Sync> Lockable<T> for RwLock<T>

Available on non-WebAssembly only.
Source§

type Guard<'a> = RwLockWriteGuard<'a, T> where Self: 'a

Source§

fn lock(&self) -> Result<Self::Guard<'_>, LockError>

Source§

impl<T: ?Sized + Send> Lockable<T> for Mutex<T>

Source§

type Guard<'a> = MutexGuard<'a, T> where Self: 'a

Source§

fn lock(&self) -> Result<Self::Guard<'_>, LockError>

Source§

impl<T: ?Sized + Send> Lockable<T> for Mutex<T>

Available on non-WebAssembly only.
Source§

type Guard<'a> = MutexGuard<'a, T> where Self: 'a

Source§

fn lock(&self) -> Result<Self::Guard<'_>, LockError>

Implementors§