Skip to main content

OwnedRwLockWriteGuard

Struct OwnedRwLockWriteGuard 

Source
pub struct OwnedRwLockWriteGuard<T: ?Sized> { /* private fields */ }
Expand description

Exclusive access to a RwLock’s value through an Arc the guard holds; releases on drop. Made by RwLock::write_owned. The release makes the progress RwLockReadGuard’s does.

Implementations§

Source§

impl<T: ?Sized> OwnedRwLockWriteGuard<T>

Source

pub fn map<F, U>(this: Self, f: F) -> OwnedRwLockMappedWriteGuard<T, U>
where U: ?Sized, F: FnOnce(&mut T) -> &mut U,

A guard for a component of the locked data. It cannot fail: this guard already holds the write.

An associated function, OwnedRwLockWriteGuard::map(guard, f): a method would shadow methods of the locked data.

Source

pub fn downgrade_map<F, U>(this: Self, f: F) -> OwnedRwLockReadGuard<T, U>
where U: ?Sized, F: FnOnce(&T) -> &U,

A read guard for a component of the locked data, made while the write is turned into a read in one step, as downgrade does. Inside f the write is still held, yet f is given only a &T: a &mut T could be kept past the downgrade through interior mutability.

Source

pub fn try_map<F, U>( this: Self, f: F, ) -> Result<OwnedRwLockMappedWriteGuard<T, U>, Self>
where U: ?Sized, F: FnOnce(&mut T) -> Option<&mut U>,

map that gives the guard back when f finds no component, with the write still held.

Source

pub fn try_downgrade_map<F, U>( this: Self, f: F, ) -> Result<OwnedRwLockReadGuard<T, U>, Self>
where U: ?Sized, F: FnOnce(&T) -> Option<&U>,

downgrade_map that gives the guard back when f finds no component: the lock is then neither released nor downgraded.

Source

pub fn into_mapped(this: Self) -> OwnedRwLockMappedWriteGuard<T>

This guard as an OwnedRwLockMappedWriteGuard, for a struct field that holds one. The same as OwnedRwLockWriteGuard::map(guard, |me| me).

Source

pub fn downgrade(self) -> OwnedRwLockReadGuard<T>

Turns the write into a read in one step, so no writer gets in between. See RwLockWriteGuard::downgrade.

Source

pub fn rwlock(this: &Self) -> &Arc<RwLock<T>> ⓘ

The Arc of the lock this guard holds the write of.

Trait Implementations§

Source§

impl<T: ?Sized + Debug> Debug for OwnedRwLockWriteGuard<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: ?Sized> Deref for OwnedRwLockWriteGuard<T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl<T: ?Sized> DerefMut for OwnedRwLockWriteGuard<T>

Source§

fn deref_mut(&mut self) -> &mut T

Mutably dereferences the value.
Source§

impl<T: ?Sized + Display> Display for OwnedRwLockWriteGuard<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: ?Sized> Drop for OwnedRwLockWriteGuard<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<T: ?Sized + Send + Sync> Send for OwnedRwLockWriteGuard<T>

Source§

impl<T: ?Sized + Send + Sync> Sync for OwnedRwLockWriteGuard<T>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> MaybeSend for T
where T: Send + ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.