pub struct DynamicManagedLazy { /* private fields */ }Expand description
Unclaimed handle to a value whose type is only known at runtime.
The ManagedLazy counterpart for script values, and the handle script
variables usually hold.
Implementations§
Source§impl DynamicManagedLazy
impl DynamicManagedLazy
Sourcepub fn new<T: ?Sized>(data: &mut T, lifetime: LifetimeLazy) -> Self
pub fn new<T: ?Sized>(data: &mut T, lifetime: LifetimeLazy) -> Self
Pairs a mutable reference with an unclaimed handle to its lifetime.
Sourcepub unsafe fn new_raw(
type_hash: TypeHash,
lifetime: LifetimeLazy,
data: *mut u8,
) -> Option<Self>
pub unsafe fn new_raw( type_hash: TypeHash, lifetime: LifetimeLazy, data: *mut u8, ) -> Option<Self>
DynamicManagedLazy::new for a type only known at runtime. A null
pointer yields None.
§Safety
data must point at a value of the type named by type_hash, and must
stay valid for as long as lifetime says it does.
Sourcepub fn make<T: ?Sized>(data: &mut T) -> (Self, Lifetime)
pub fn make<T: ?Sized>(data: &mut T) -> (Self, Lifetime)
Builds a handle to a plain mutable reference along with the lifetime that backs it.
Sourcepub fn into_inner(self) -> (TypeHash, LifetimeLazy, *mut u8)
pub fn into_inner(self) -> (TypeHash, LifetimeLazy, *mut u8)
Splits into type, lifetime handle and pointer.
Sourcepub fn into_typed<T>(self) -> Result<ManagedLazy<T>, Self>
pub fn into_typed<T>(self) -> Result<ManagedLazy<T>, Self>
Recovers the typed handle, or gives self back on a type mismatch.
Sourcepub fn lifetime(&self) -> &LifetimeLazy
pub fn lifetime(&self) -> &LifetimeLazy
Returns the lifetime handle.
Sourcepub fn read<T>(&self) -> Option<ValueReadAccess<'_, T>>
pub fn read<T>(&self) -> Option<ValueReadAccess<'_, T>>
Guards the value for reading, or returns None on a type mismatch or
while it is written.
Sourcepub fn write<T>(&self) -> Option<ValueWriteAccess<'_, T>>
pub fn write<T>(&self) -> Option<ValueWriteAccess<'_, T>>
Guards the value for writing, or returns None on a type mismatch or
while it is accessed.
Takes &self, since a lazy handle claims nothing of its own.
Sourcepub fn borrow(&self) -> Option<DynamicManagedRef>
pub fn borrow(&self) -> Option<DynamicManagedRef>
Upgrades to a shared handle that holds its claim.
Sourcepub fn borrow_mut(&mut self) -> Option<DynamicManagedRefMut>
pub fn borrow_mut(&mut self) -> Option<DynamicManagedRefMut>
Upgrades to an exclusive handle that holds its claim.
Sourcepub unsafe fn try_map<T, U>(
self,
f: impl FnOnce(&mut T) -> Option<&mut U>,
) -> Option<Self>
pub unsafe fn try_map<T, U>( self, f: impl FnOnce(&mut T) -> Option<&mut U>, ) -> Option<Self>
Sourcepub unsafe fn as_ptr<T>(&self) -> Option<*const T>
pub unsafe fn as_ptr<T>(&self) -> Option<*const T>
Returns a typed pointer while the owner is alive.
§Safety
The caller takes over checking for conflicting access.
Sourcepub unsafe fn as_mut_ptr<T>(&self) -> Option<*mut T>
pub unsafe fn as_mut_ptr<T>(&self) -> Option<*mut T>
Returns a typed mutable pointer while the owner is alive.
§Safety
The caller takes over checking for conflicting access.