Skip to main content

LifetimeRefMut

Struct LifetimeRefMut 

Source
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

Source

pub fn state(&self) -> &LifetimeWeakState

Returns the weak state this borrow points at.

Source

pub fn tag(&self) -> usize

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

Source

pub fn depth(&self) -> usize

Returns how deeply this mutable borrow is nested, starting at 1.

Source

pub fn exists(&self) -> bool

Returns true while the owning Lifetime is alive and valid.

Source

pub fn can_read(&self) -> bool

Returns true when a shared borrow could be taken.

Source

pub fn can_write(&self) -> bool

Returns true when this borrow could be reborrowed mutably.

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 borrow came from other.

Source

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

Takes a shared borrow, which only succeeds once this mutable borrow is not the innermost one.

Source

pub async fn borrow_async(&self) -> LifetimeRef

LifetimeRefMut::borrow, awaiting until it succeeds.

Source

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

Reborrows mutably one level deeper, or returns None when this is not the innermost mutable borrow.

Source

pub async fn borrow_mut_async(&self) -> LifetimeRefMut

LifetimeRefMut::borrow_mut, awaiting until it succeeds.

Source

pub fn lazy(&self) -> LifetimeLazy

Takes a lazy handle to the same lifetime.

Source

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.

Source

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

LifetimeRefMut::read, awaiting until it succeeds.

Source

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.

Source

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.

Source

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.

Source

pub async fn write_async<'a, T: ?Sized>( &'a self, data: &'a mut T, ) -> ValueWriteAccess<'a, T>

LifetimeRefMut::write, awaiting until it succeeds.

Source

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.

Source

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.

Source

pub fn try_read_lock(&self) -> Option<ReadLock>

Claims read access without holding any data.

Source

pub fn read_lock(&self) -> Option<ReadLock>

LifetimeRefMut::try_read_lock, spinning until it succeeds. Returns None when the owner is gone.

Source

pub async fn read_lock_async(&self) -> ReadLock

LifetimeRefMut::read_lock, awaiting until it succeeds.

Source

pub fn try_write_lock(&self) -> Option<WriteLock>

Claims write access without holding any data.

Source

pub fn write_lock(&self) -> Option<WriteLock>

LifetimeRefMut::try_write_lock, spinning until it succeeds. Returns None when the owner is gone.

Source

pub async fn write_lock_async(&self) -> WriteLock

LifetimeRefMut::write_lock, awaiting until it succeeds.

Source

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.

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 Drop for LifetimeRefMut

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

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> 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, 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.