pub struct DynamicManagedRefMut { /* private fields */ }Expand description
Exclusive handle to a value whose type is only known at runtime.
The ManagedRefMut counterpart for script values.
Implementations§
Source§impl DynamicManagedRefMut
impl DynamicManagedRefMut
Sourcepub fn new<T: ?Sized>(data: &mut T, lifetime: LifetimeRefMut) -> Self
pub fn new<T: ?Sized>(data: &mut T, lifetime: LifetimeRefMut) -> Self
Pairs a mutable reference with an exclusive borrow of its lifetime.
Sourcepub unsafe fn new_raw(
type_hash: TypeHash,
lifetime: LifetimeRefMut,
data: *mut u8,
) -> Option<Self>
pub unsafe fn new_raw( type_hash: TypeHash, lifetime: LifetimeRefMut, data: *mut u8, ) -> Option<Self>
DynamicManagedRefMut::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 and unaliased 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, LifetimeRefMut, *mut u8)
pub fn into_inner(self) -> (TypeHash, LifetimeRefMut, *mut u8)
Splits into type, borrow token and pointer.
Sourcepub fn into_typed<T>(self) -> Result<ManagedRefMut<T>, Self>
pub fn into_typed<T>(self) -> Result<ManagedRefMut<T>, Self>
Recovers the typed handle, or gives self back on a type mismatch.
Sourcepub fn lifetime(&self) -> &LifetimeRefMut
pub fn lifetime(&self) -> &LifetimeRefMut
Returns the borrow token.
Sourcepub fn borrow(&self) -> Option<DynamicManagedRef>
pub fn borrow(&self) -> Option<DynamicManagedRef>
Takes a shared handle nested under this one.
Sourcepub fn borrow_mut(&mut self) -> Option<DynamicManagedRefMut>
pub fn borrow_mut(&mut self) -> Option<DynamicManagedRefMut>
Takes an exclusive handle nested under this one.
Sourcepub fn lazy(&self) -> DynamicManagedLazy
pub fn lazy(&self) -> DynamicManagedLazy
Takes an unclaimed 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>(&mut self) -> Option<ValueWriteAccess<'_, T>>
pub fn write<T>(&mut self) -> Option<ValueWriteAccess<'_, T>>
Guards the value for writing, or returns None on a type mismatch or
while it is accessed.
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>(&mut self) -> Option<*mut T>
pub unsafe fn as_mut_ptr<T>(&mut self) -> Option<*mut T>
Returns a typed mutable pointer while the owner is alive.
§Safety
The caller takes over checking for conflicting access.