pub struct LifetimeRef(/* private fields */);Expand description
Shared borrow of a Lifetime, the runtime analogue of &T.
Many can coexist and they keep mutable borrows out. Releases its claim on drop.
Implementations§
Source§impl LifetimeRef
impl LifetimeRef
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_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 another shared borrow of the same lifetime.
Sourcepub async fn borrow_async(&self) -> LifetimeRef
pub async fn borrow_async(&self) -> LifetimeRef
LifetimeRef::borrow, 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>
LifetimeRef::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>>
LifetimeRef::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>
LifetimeRef::read_ptr, awaiting until it succeeds.
§Safety
Same as LifetimeRef::read_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>
LifetimeRef::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
LifetimeRef::read_lock, awaiting until it succeeds.
Sourcepub fn consume<T: ?Sized>(
self,
data: &T,
) -> Result<ValueReadAccess<'_, T>, Self>
pub fn consume<T: ?Sized>( self, data: &T, ) -> Result<ValueReadAccess<'_, T>, Self>
Turns this borrow into a read guard over data that lives as long as
the borrow would have.
Gives the borrow back unchanged when a write 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.