pub struct LifetimeLazy(/* private fields */);Expand description
Handle that claims nothing until it is used.
Unlike LifetimeRef and LifetimeRefMut, holding one blocks
nobody, and it can be cloned freely. Each call checks the conditions
again, so it is the right handle for a value that is looked up now and
touched later, such as a script variable.
Implementations§
Source§impl LifetimeLazy
impl LifetimeLazy
Sourcepub fn state(&self) -> &LifetimeWeakState
pub fn state(&self) -> &LifetimeWeakState
Returns the weak state this handle 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 handle came from other.
Sourcepub fn borrow(&self) -> Option<LifetimeRef>
pub fn borrow(&self) -> Option<LifetimeRef>
Upgrades to a real shared borrow.
Sourcepub async fn borrow_async(&self) -> LifetimeRef
pub async fn borrow_async(&self) -> LifetimeRef
LifetimeLazy::borrow, awaiting until it succeeds.
Sourcepub fn borrow_mut(&self) -> Option<LifetimeRefMut>
pub fn borrow_mut(&self) -> Option<LifetimeRefMut>
Upgrades to a real top level mutable borrow, which needs no other borrow to be out.
Sourcepub async fn borrow_mut_async(&self) -> LifetimeRefMut
pub async fn borrow_mut_async(&self) -> LifetimeRefMut
LifetimeLazy::borrow_mut, awaiting until it succeeds.
Sourcepub fn read<'a, T>(&'a self, data: &'a T) -> Option<ValueReadAccess<'a, T>>where
T: ?Sized,
pub fn read<'a, T>(&'a self, data: &'a T) -> Option<ValueReadAccess<'a, T>>where
T: ?Sized,
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>(&'a self, data: &'a T) -> ValueReadAccess<'a, T>where
T: ?Sized,
pub async fn read_async<'a, T>(&'a self, data: &'a T) -> ValueReadAccess<'a, T>where
T: ?Sized,
LifetimeLazy::read, awaiting until it succeeds.
Sourcepub unsafe fn read_ptr<T>(
&self,
data: *const T,
) -> Option<ValueReadAccess<'_, T>>where
T: ?Sized,
pub unsafe fn read_ptr<T>(
&self,
data: *const T,
) -> Option<ValueReadAccess<'_, T>>where
T: ?Sized,
LifetimeLazy::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>(
&'a self,
data: *const T,
) -> ValueReadAccess<'a, T>where
T: 'a + ?Sized,
pub async unsafe fn read_ptr_async<'a, T>(
&'a self,
data: *const T,
) -> ValueReadAccess<'a, T>where
T: 'a + ?Sized,
LifetimeLazy::read_ptr, awaiting until it succeeds.
§Safety
Same as LifetimeLazy::read_ptr, and data must also stay valid
across every await point.
Sourcepub fn write<'a, T>(
&'a self,
data: &'a mut T,
) -> Option<ValueWriteAccess<'a, T>>where
T: ?Sized,
pub fn write<'a, T>(
&'a self,
data: &'a mut T,
) -> Option<ValueWriteAccess<'a, T>>where
T: ?Sized,
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>(
&'a self,
data: &'a mut T,
) -> ValueWriteAccess<'a, T>where
T: ?Sized,
pub async fn write_async<'a, T>(
&'a self,
data: &'a mut T,
) -> ValueWriteAccess<'a, T>where
T: ?Sized,
LifetimeLazy::write, awaiting until it succeeds.
Sourcepub unsafe fn write_ptr<T>(
&self,
data: *mut T,
) -> Option<ValueWriteAccess<'_, T>>where
T: ?Sized,
pub unsafe fn write_ptr<T>(
&self,
data: *mut T,
) -> Option<ValueWriteAccess<'_, T>>where
T: ?Sized,
LifetimeLazy::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>(
&'a self,
data: *mut T,
) -> ValueWriteAccess<'a, T>where
T: 'a + ?Sized,
pub async unsafe fn write_ptr_async<'a, T>(
&'a self,
data: *mut T,
) -> ValueWriteAccess<'a, T>where
T: 'a + ?Sized,
LifetimeLazy::write_ptr, awaiting until it succeeds.
§Safety
Same as LifetimeLazy::write_ptr, and data must also stay valid
across every await point.
Sourcepub fn consume<T>(
self,
data: &mut T,
) -> Result<ValueWriteAccess<'_, T>, LifetimeLazy>where
T: ?Sized,
pub fn consume<T>(
self,
data: &mut T,
) -> Result<ValueWriteAccess<'_, T>, LifetimeLazy>where
T: ?Sized,
Turns this handle into a write guard over data.
Gives the handle 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.
Trait Implementations§
Source§impl Clone for LifetimeLazy
impl Clone for LifetimeLazy
Source§fn clone(&self) -> LifetimeLazy
fn clone(&self) -> LifetimeLazy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more