RwLock

Trait RwLock 

Source
pub trait RwLock {
    type ReadError<'a>
       where Self: 'a;
    type WriteError<'a>
       where Self: 'a;
    type ReadGuard<'a>
       where Self: 'a;
    type WriteGuard<'a>
       where Self: 'a;

    // Required methods
    fn read(&self) -> Result<Self::ReadGuard<'_>, Self::ReadError<'_>>;
    fn write(&self) -> Result<Self::WriteGuard<'_>, Self::WriteError<'_>>;
}
Expand description

Locking implementation for crate::ReadWrite.

Describes how to acquire access to the state for a crate::LockLevel implementation with Method = ReadWrite. The error and RAII guard types are implementation-defined.

Required Associated Types§

Source

type ReadError<'a> where Self: 'a

Error that could be produced when acquiring read access.

For implementations where acquiring a lock is an infallible operation, the error type core::convert::Infallible can be used.

Source

type WriteError<'a> where Self: 'a

Error that could be produced when acquiring write access.

For implementations where acquiring a lock is an infallible operation, the error type core::convert::Infallible can be used.

Source

type ReadGuard<'a> where Self: 'a

RAII guard for shared access to data protected by the lock.

Source

type WriteGuard<'a> where Self: 'a

RAII guard for exclusive access to data protected by the lock.

Required Methods§

Source

fn read(&self) -> Result<Self::ReadGuard<'_>, Self::ReadError<'_>>

Attempts to acquire shared access to data.

Returns an RAII guard that provides shared (read) access to the data, or an error on failure.

Source

fn write(&self) -> Result<Self::WriteGuard<'_>, Self::WriteError<'_>>

Attempts to acquire exclusive access to data.

Returns an RAII guard that provides exclusive (read/write) access to the data, or an error on failure.

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> RwLock for RwLock<T>

Source§

type ReadError<'a> = PoisonError<RwLockReadGuard<'a, T>> where Self: 'a

Source§

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

Source§

type ReadGuard<'a> = RwLockReadGuard<'a, T> where Self: 'a

Source§

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

Source§

fn read(&self) -> Result<Self::ReadGuard<'_>, Self::ReadError<'_>>

Source§

fn write(&self) -> Result<Self::WriteGuard<'_>, Self::WriteError<'_>>

Implementors§