pub struct ManagedLazy<T: ?Sized> { /* private fields */ }Expand description
Unclaimed handle to a value owned by a Managed.
Holding one blocks nobody, and it can be cloned freely. Every access is checked when it happens. This is the handle a script variable holds, because such a variable is read and written at any point, with no Rust borrow to model it.
Implementations§
Source§impl<T: ?Sized> ManagedLazy<T>
impl<T: ?Sized> ManagedLazy<T>
Sourcepub fn new(data: &mut T, lifetime: LifetimeLazy) -> Self
pub fn new(data: &mut T, lifetime: LifetimeLazy) -> Self
Pairs a mutable reference with an unclaimed handle to its lifetime.
Sourcepub unsafe fn new_raw(data: *mut T, lifetime: LifetimeLazy) -> Option<Self>
pub unsafe fn new_raw(data: *mut T, lifetime: LifetimeLazy) -> Option<Self>
ManagedLazy::new over a raw pointer. A null pointer yields None.
§Safety
data must stay valid for as long as lifetime says it does, and
lifetime must be the borrow state that guards it.
Sourcepub fn make(data: &mut T) -> (Self, Lifetime)
pub fn make(data: &mut T) -> (Self, Lifetime)
Builds a handle to a plain mutable reference along with the lifetime that backs it.
The caller has to keep the returned Lifetime alive for at least as
long as the handle.
Sourcepub unsafe fn make_raw(data: *mut T) -> Option<(Self, Lifetime)>
pub unsafe fn make_raw(data: *mut T) -> Option<(Self, Lifetime)>
ManagedLazy::make over a raw pointer.
§Safety
data must stay valid for as long as the returned handle lives.
Sourcepub fn into_inner(self) -> (LifetimeLazy, *mut T)
pub fn into_inner(self) -> (LifetimeLazy, *mut T)
Splits into the lifetime handle and the pointer.
Sourcepub fn into_dynamic(self) -> DynamicManagedLazy
pub fn into_dynamic(self) -> DynamicManagedLazy
Erases the type, keeping the same handle.
Sourcepub fn lifetime(&self) -> &LifetimeLazy
pub fn lifetime(&self) -> &LifetimeLazy
Returns the lifetime handle.
Sourcepub fn borrow(&self) -> Option<ManagedRef<T>>
pub fn borrow(&self) -> Option<ManagedRef<T>>
Upgrades to a shared handle that holds its claim.
Sourcepub fn borrow_mut(&mut self) -> Option<ManagedRefMut<T>>
pub fn borrow_mut(&mut self) -> Option<ManagedRefMut<T>>
Upgrades to an exclusive handle that holds its claim.
Sourcepub fn read(&self) -> Option<ValueReadAccess<'_, T>>
pub fn read(&self) -> Option<ValueReadAccess<'_, T>>
Guards the value for reading, or returns None when it is written or
the owner is gone.
Sourcepub fn write(&self) -> Option<ValueWriteAccess<'_, T>>
pub fn write(&self) -> Option<ValueWriteAccess<'_, T>>
Guards the value for writing, or returns None when it is accessed or
the owner is gone.
Takes &self, since a lazy handle claims nothing of its own.
Sourcepub unsafe fn map<U>(self, f: impl FnOnce(&mut T) -> &mut U) -> ManagedLazy<U>
pub unsafe fn map<U>(self, f: impl FnOnce(&mut T) -> &mut U) -> ManagedLazy<U>
Narrows this handle down to a part of the value, such as one field.
§Safety
f must return a reference into the same value, and the owner must
still be alive.
Sourcepub unsafe fn try_map<U>(
self,
f: impl FnOnce(&mut T) -> Option<&mut U>,
) -> Option<ManagedLazy<U>>
pub unsafe fn try_map<U>( self, f: impl FnOnce(&mut T) -> Option<&mut U>, ) -> Option<ManagedLazy<U>>
Sourcepub unsafe fn as_ptr(&self) -> Option<*const T>
pub unsafe fn as_ptr(&self) -> Option<*const T>
Returns the pointer while the owner is alive, bypassing access checks.
§Safety
The caller takes over checking for conflicting access.
Sourcepub unsafe fn as_mut_ptr(&self) -> Option<*mut T>
pub unsafe fn as_mut_ptr(&self) -> Option<*mut T>
Returns the mutable pointer while the owner is alive, bypassing access checks.
§Safety
The caller takes over checking for conflicting access.