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>(data: &mut T, lifetime: LifetimeLazy) -> DynamicManagedLazywhere
T: ?Sized,
pub fn new<T>(data: &mut T, lifetime: LifetimeLazy) -> DynamicManagedLazywhere
T: ?Sized,
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<DynamicManagedLazy>
pub unsafe fn new_raw( type_hash: TypeHash, lifetime: LifetimeLazy, data: *mut u8, ) -> Option<DynamicManagedLazy>
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>(data: &mut T) -> (DynamicManagedLazy, Lifetime)where
T: ?Sized,
pub fn make<T>(data: &mut T) -> (DynamicManagedLazy, Lifetime)where
T: ?Sized,
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>, DynamicManagedLazy>
pub fn into_typed<T>(self) -> Result<ManagedLazy<T>, DynamicManagedLazy>
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 map<T, U>(
self,
f: impl FnOnce(&mut T) -> &mut U,
) -> Option<DynamicManagedLazy>
pub unsafe fn map<T, U>( self, f: impl FnOnce(&mut T) -> &mut U, ) -> Option<DynamicManagedLazy>
Sourcepub unsafe fn try_map<T, U>(
self,
f: impl FnOnce(&mut T) -> Option<&mut U>,
) -> Option<DynamicManagedLazy>
pub unsafe fn try_map<T, U>( self, f: impl FnOnce(&mut T) -> Option<&mut U>, ) -> Option<DynamicManagedLazy>
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.
Trait Implementations§
Source§impl Clone for DynamicManagedLazy
impl Clone for DynamicManagedLazy
Source§fn clone(&self) -> DynamicManagedLazy
fn clone(&self) -> DynamicManagedLazy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more