Skip to main content

LifetimeLazy

Struct LifetimeLazy 

Source
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

Source

pub fn state(&self) -> &LifetimeWeakState

Returns the weak state this handle points at.

Source

pub fn tag(&self) -> usize

Returns the tag the owner had when this handle was taken.

Source

pub fn exists(&self) -> bool

Returns true while the owning Lifetime is alive and valid.

Source

pub fn is_read_accessible(&self) -> bool

Returns true when no write guard is live.

Source

pub fn is_write_accessible(&self) -> bool

Returns true when no access guard of any kind is live.

Source

pub fn is_in_use(&self) -> bool

Returns true while any access guard is live.

Source

pub fn is_owned_by(&self, other: &Lifetime) -> bool

Returns true when this handle came from other.

Source

pub fn borrow(&self) -> Option<LifetimeRef>

Upgrades to a real shared borrow.

Source

pub async fn borrow_async(&self) -> LifetimeRef

LifetimeLazy::borrow, awaiting until it succeeds.

Source

pub fn borrow_mut(&self) -> Option<LifetimeRefMut>

Upgrades to a real top level mutable borrow, which needs no other borrow to be out.

Source

pub async fn borrow_mut_async(&self) -> LifetimeRefMut

LifetimeLazy::borrow_mut, awaiting until it succeeds.

Source

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.

Source

pub async fn read_async<'a, T>(&'a self, data: &'a T) -> ValueReadAccess<'a, T>
where T: ?Sized,

LifetimeLazy::read, awaiting until it succeeds.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn wait_for_read_access(&self)

Awaits until reading would be allowed, or the owner is gone.

Source

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

Source§

fn clone(&self) -> LifetimeLazy

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Finalize for T

Source§

unsafe fn finalize_raw(data: *mut ())

Drops the value stored at data in place. 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.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.