pub struct LifetimeRefMut(/* private fields */);Expand description
Mutable borrow of a Lifetime, the runtime analogue of &mut T.
Excludes every other top level borrow, but can reborrow itself through
LifetimeRefMut::borrow_mut, which nests one level deeper. Releases
its level, and everything nested under it, on drop.
Implementations§
Source§impl LifetimeRefMut
impl LifetimeRefMut
Sourcepub fn state(&self) -> &LifetimeWeakState
pub fn state(&self) -> &LifetimeWeakState
Returns the weak state this borrow points at.
Sourcepub fn is_read_accessible(&self) -> bool
pub fn is_read_accessible(&self) -> bool
Returns true when no write guard is live.
Sourcepub fn is_write_accessible(&self) -> bool
pub fn is_write_accessible(&self) -> bool
Returns true when no access guard of any kind is live.
Sourcepub fn is_owned_by(&self, other: &Lifetime) -> bool
pub fn is_owned_by(&self, other: &Lifetime) -> bool
Returns true when this borrow came from other.
Sourcepub fn borrow(&self) -> Option<LifetimeRef>
pub fn borrow(&self) -> Option<LifetimeRef>
Takes a shared borrow, which only succeeds once this mutable borrow is not the innermost one.
Sourcepub async fn borrow_async(&self) -> LifetimeRef
pub async fn borrow_async(&self) -> LifetimeRef
LifetimeRefMut::borrow, awaiting until it succeeds.
Sourcepub fn borrow_mut(&self) -> Option<LifetimeRefMut>
pub fn borrow_mut(&self) -> Option<LifetimeRefMut>
Reborrows mutably one level deeper, or returns None when this is not
the innermost mutable borrow.
Sourcepub async fn borrow_mut_async(&self) -> LifetimeRefMut
pub async fn borrow_mut_async(&self) -> LifetimeRefMut
LifetimeRefMut::borrow_mut, awaiting until it succeeds.
Sourcepub fn lazy(&self) -> LifetimeLazy
pub fn lazy(&self) -> LifetimeLazy
Takes a lazy handle to the same lifetime.
Sourcepub fn read<'a, T: ?Sized>(
&'a self,
data: &'a T,
) -> Option<ValueReadAccess<'a, T>>
pub fn read<'a, T: ?Sized>( &'a self, data: &'a T, ) -> Option<ValueReadAccess<'a, T>>
Guards data for reading, or returns None while a write guard is
live or the owner is gone.
Sourcepub async fn read_async<'a, T: ?Sized>(
&'a self,
data: &'a T,
) -> ValueReadAccess<'a, T>
pub async fn read_async<'a, T: ?Sized>( &'a self, data: &'a T, ) -> ValueReadAccess<'a, T>
LifetimeRefMut::read, awaiting until it succeeds.
Sourcepub unsafe fn read_ptr<T: ?Sized>(
&self,
data: *const T,
) -> Option<ValueReadAccess<'_, T>>
pub unsafe fn read_ptr<T: ?Sized>( &self, data: *const T, ) -> Option<ValueReadAccess<'_, T>>
LifetimeRefMut::read over a raw pointer.
§Safety
data must stay valid and aligned for as long as the returned guard
lives. A null pointer yields None.
Sourcepub async unsafe fn read_ptr_async<'a, T: ?Sized + 'a>(
&'a self,
data: *const T,
) -> ValueReadAccess<'a, T>
pub async unsafe fn read_ptr_async<'a, T: ?Sized + 'a>( &'a self, data: *const T, ) -> ValueReadAccess<'a, T>
LifetimeRefMut::read_ptr, awaiting until it succeeds.
§Safety
Same as LifetimeRefMut::read_ptr, and data must also stay valid
across every await point.
Sourcepub fn write<'a, T: ?Sized>(
&'a self,
data: &'a mut T,
) -> Option<ValueWriteAccess<'a, T>>
pub fn write<'a, T: ?Sized>( &'a self, data: &'a mut T, ) -> Option<ValueWriteAccess<'a, T>>
Guards data for writing, or returns None while any other access
guard is live or the owner is gone.
Sourcepub async fn write_async<'a, T: ?Sized>(
&'a self,
data: &'a mut T,
) -> ValueWriteAccess<'a, T>
pub async fn write_async<'a, T: ?Sized>( &'a self, data: &'a mut T, ) -> ValueWriteAccess<'a, T>
LifetimeRefMut::write, awaiting until it succeeds.
Sourcepub unsafe fn write_ptr<T: ?Sized>(
&self,
data: *mut T,
) -> Option<ValueWriteAccess<'_, T>>
pub unsafe fn write_ptr<T: ?Sized>( &self, data: *mut T, ) -> Option<ValueWriteAccess<'_, T>>
LifetimeRefMut::write over a raw pointer.
§Safety
data must stay valid, aligned and unaliased for as long as the
returned guard lives. A null pointer yields None.
Sourcepub async unsafe fn write_ptr_async<'a, T: ?Sized + 'a>(
&'a self,
data: *mut T,
) -> ValueWriteAccess<'a, T>
pub async unsafe fn write_ptr_async<'a, T: ?Sized + 'a>( &'a self, data: *mut T, ) -> ValueWriteAccess<'a, T>
LifetimeRefMut::write_ptr, awaiting until it succeeds.
§Safety
Same as LifetimeRefMut::write_ptr, and data must also stay valid
across every await point.
Sourcepub fn try_read_lock(&self) -> Option<ReadLock>
pub fn try_read_lock(&self) -> Option<ReadLock>
Claims read access without holding any data.
Sourcepub fn read_lock(&self) -> Option<ReadLock>
pub fn read_lock(&self) -> Option<ReadLock>
LifetimeRefMut::try_read_lock, spinning until it succeeds. Returns
None when the owner is gone.
Sourcepub async fn read_lock_async(&self) -> ReadLock
pub async fn read_lock_async(&self) -> ReadLock
LifetimeRefMut::read_lock, awaiting until it succeeds.
Sourcepub fn try_write_lock(&self) -> Option<WriteLock>
pub fn try_write_lock(&self) -> Option<WriteLock>
Claims write access without holding any data.
Sourcepub fn write_lock(&self) -> Option<WriteLock>
pub fn write_lock(&self) -> Option<WriteLock>
LifetimeRefMut::try_write_lock, spinning until it succeeds. Returns
None when the owner is gone.
Sourcepub async fn write_lock_async(&self) -> WriteLock
pub async fn write_lock_async(&self) -> WriteLock
LifetimeRefMut::write_lock, awaiting until it succeeds.
Sourcepub fn consume<T: ?Sized>(
self,
data: &mut T,
) -> Result<ValueWriteAccess<'_, T>, Self>
pub fn consume<T: ?Sized>( self, data: &mut T, ) -> Result<ValueWriteAccess<'_, T>, Self>
Turns this borrow into a write guard over data that lives as long as
the borrow would have.
Gives the borrow back unchanged when another access guard is live.
Sourcepub async fn wait_for_read_access(&self)
pub async fn wait_for_read_access(&self)
Awaits until reading would be allowed, or the owner is gone.
Sourcepub async fn wait_for_write_access(&self)
pub async fn wait_for_write_access(&self)
Awaits until writing would be allowed, or the owner is gone.