pub enum DynamicManagedValue {
Owned(DynamicManaged),
Ref(DynamicManagedRef),
RefMut(DynamicManagedRefMut),
Lazy(DynamicManagedLazy),
Gc(DynamicManagedGc),
}Expand description
A value of a runtime known type, held in any of the possible ways.
The ManagedValue counterpart for script values.
Variants§
Owned(DynamicManaged)
The value itself.
Ref(DynamicManagedRef)
A shared handle to someone else’s value.
RefMut(DynamicManagedRefMut)
An exclusive handle to someone else’s value.
Lazy(DynamicManagedLazy)
An unclaimed handle to someone else’s value.
Gc(DynamicManagedGc)
A garbage collected handle, owning or referencing.
Implementations§
Source§impl DynamicManagedValue
impl DynamicManagedValue
Sourcepub fn as_owned(&self) -> Option<&DynamicManaged>
pub fn as_owned(&self) -> Option<&DynamicManaged>
Returns the owned value, or None for any other role.
Sourcepub fn as_mut_owned(&mut self) -> Option<&mut DynamicManaged>
pub fn as_mut_owned(&mut self) -> Option<&mut DynamicManaged>
Returns the owned value mutably, or None for any other role.
Sourcepub fn as_ref(&self) -> Option<&DynamicManagedRef>
pub fn as_ref(&self) -> Option<&DynamicManagedRef>
Returns the shared handle, or None for any other role.
Sourcepub fn as_mut_ref(&mut self) -> Option<&mut DynamicManagedRef>
pub fn as_mut_ref(&mut self) -> Option<&mut DynamicManagedRef>
Returns the shared handle mutably, or None for any other role.
Sourcepub fn as_ref_mut(&self) -> Option<&DynamicManagedRefMut>
pub fn as_ref_mut(&self) -> Option<&DynamicManagedRefMut>
Returns the exclusive handle, or None for any other role.
Sourcepub fn as_mut_ref_mut(&mut self) -> Option<&mut DynamicManagedRefMut>
pub fn as_mut_ref_mut(&mut self) -> Option<&mut DynamicManagedRefMut>
Returns the exclusive handle mutably, or None for any other role.
Sourcepub fn as_lazy(&self) -> Option<&DynamicManagedLazy>
pub fn as_lazy(&self) -> Option<&DynamicManagedLazy>
Returns the unclaimed handle, or None for any other role.
Sourcepub fn as_mut_lazy(&mut self) -> Option<&mut DynamicManagedLazy>
pub fn as_mut_lazy(&mut self) -> Option<&mut DynamicManagedLazy>
Returns the unclaimed handle mutably, or None for any other role.
Sourcepub fn as_gc(&self) -> Option<&DynamicManagedGc>
pub fn as_gc(&self) -> Option<&DynamicManagedGc>
Returns the garbage collected handle, or None for any other role.
Sourcepub fn as_mut_gc(&mut self) -> Option<&mut DynamicManagedGc>
pub fn as_mut_gc(&mut self) -> Option<&mut DynamicManagedGc>
Returns the garbage collected handle mutably, or None for any other role.
Sourcepub fn read<T>(&self) -> Option<ValueReadAccess<'_, T>>
pub fn read<T>(&self) -> Option<ValueReadAccess<'_, T>>
Guards the value for reading, whichever role holds it.
Returns None when the value is not a T.
Sourcepub fn write<T>(&mut self) -> Option<ValueWriteAccess<'_, T>>
pub fn write<T>(&mut self) -> Option<ValueWriteAccess<'_, T>>
Guards the value for writing.
Always None for a shared handle, or when the value is not a T.
Sourcepub fn borrow(&self) -> Option<DynamicManagedRef>
pub fn borrow(&self) -> Option<DynamicManagedRef>
Takes a shared handle to the value.
Always None for an unclaimed handle, which cannot lend its claim.
Sourcepub fn borrow_mut(&mut self) -> Option<DynamicManagedRefMut>
pub fn borrow_mut(&mut self) -> Option<DynamicManagedRefMut>
Takes an exclusive handle to the value.
Always None for shared and unclaimed handles.
Sourcepub fn lazy(&self) -> Option<DynamicManagedLazy>
pub fn lazy(&self) -> Option<DynamicManagedLazy>
Takes an unclaimed handle to the value.
Always None for a shared handle. See
DynamicManagedValue::lazy_immutable.
Sourcepub unsafe fn lazy_immutable(&self) -> DynamicManagedLazy
pub unsafe fn lazy_immutable(&self) -> DynamicManagedLazy
DynamicManagedValue::lazy that also works for a shared handle.
§Safety
For a shared handle, the result can write to a value that was only borrowed immutably.
Sourcepub fn into_typed<T>(self) -> Result<ManagedValue<T>, Self>
pub fn into_typed<T>(self) -> Result<ManagedValue<T>, Self>
Recovers the typed value, giving self back on a type mismatch.