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§
Sourcetype ReadError<'a>
where
Self: 'a
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.
Sourcetype WriteError<'a>
where
Self: 'a
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.
Sourcetype ReadGuard<'a>
where
Self: 'a
type ReadGuard<'a> where Self: 'a
RAII guard for shared access to data protected by the lock.
Sourcetype WriteGuard<'a>
where
Self: 'a
type WriteGuard<'a> where Self: 'a
RAII guard for exclusive access to data protected by the lock.
Required Methods§
Sourcefn read(&self) -> Result<Self::ReadGuard<'_>, Self::ReadError<'_>>
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.
Sourcefn write(&self) -> Result<Self::WriteGuard<'_>, Self::WriteError<'_>>
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.