pub enum ManagedValue<T> {
Owned(Managed<T>),
Ref(ManagedRef<T>),
RefMut(ManagedRefMut<T>),
Lazy(ManagedLazy<T>),
Gc(ManagedGc<T>),
}Expand description
A typed value held in any of the possible ways.
See the module docs.
Variants§
Owned(Managed<T>)
The value itself.
Ref(ManagedRef<T>)
A shared handle to someone else’s value.
RefMut(ManagedRefMut<T>)
An exclusive handle to someone else’s value.
Lazy(ManagedLazy<T>)
An unclaimed handle to someone else’s value.
Gc(ManagedGc<T>)
A garbage collected handle, owning or referencing.
Implementations§
Source§impl<T> ManagedValue<T>
impl<T> ManagedValue<T>
Sourcepub fn as_owned(&self) -> Option<&Managed<T>>
pub fn as_owned(&self) -> Option<&Managed<T>>
Returns the owned value, or None for any other role.
Sourcepub fn as_mut_owned(&mut self) -> Option<&mut Managed<T>>
pub fn as_mut_owned(&mut self) -> Option<&mut Managed<T>>
Returns the owned value mutably, or None for any other role.
Sourcepub fn as_ref(&self) -> Option<&ManagedRef<T>>
pub fn as_ref(&self) -> Option<&ManagedRef<T>>
Returns the shared handle, or None for any other role.
Sourcepub fn as_mut_ref(&mut self) -> Option<&mut ManagedRef<T>>
pub fn as_mut_ref(&mut self) -> Option<&mut ManagedRef<T>>
Returns the shared handle mutably, or None for any other role.
Sourcepub fn as_ref_mut(&self) -> Option<&ManagedRefMut<T>>
pub fn as_ref_mut(&self) -> Option<&ManagedRefMut<T>>
Returns the exclusive handle, or None for any other role.
Sourcepub fn as_mut_ref_mut(&mut self) -> Option<&mut ManagedRefMut<T>>
pub fn as_mut_ref_mut(&mut self) -> Option<&mut ManagedRefMut<T>>
Returns the exclusive handle mutably, or None for any other role.
Sourcepub fn as_lazy(&self) -> Option<&ManagedLazy<T>>
pub fn as_lazy(&self) -> Option<&ManagedLazy<T>>
Returns the unclaimed handle, or None for any other role.
Sourcepub fn as_mut_lazy(&mut self) -> Option<&mut ManagedLazy<T>>
pub fn as_mut_lazy(&mut self) -> Option<&mut ManagedLazy<T>>
Returns the unclaimed handle mutably, or None for any other role.
Sourcepub fn as_gc(&self) -> Option<&ManagedGc<T>>
pub fn as_gc(&self) -> Option<&ManagedGc<T>>
Returns the garbage collected handle, or None for any other role.
Sourcepub fn as_mut_gc(&mut self) -> Option<&mut ManagedGc<T>>
pub fn as_mut_gc(&mut self) -> Option<&mut ManagedGc<T>>
Returns the garbage collected handle mutably, or None for any other role.
Sourcepub fn read(&self) -> Option<ValueReadAccess<'_, T>>
pub fn read(&self) -> Option<ValueReadAccess<'_, T>>
Guards the value for reading, whichever role holds it.
Sourcepub fn write(&mut self) -> Option<ValueWriteAccess<'_, T>>
pub fn write(&mut self) -> Option<ValueWriteAccess<'_, T>>
Guards the value for writing.
Always None for a shared handle.
Sourcepub fn borrow(&self) -> Option<ManagedRef<T>>
pub fn borrow(&self) -> Option<ManagedRef<T>>
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<ManagedRefMut<T>>
pub fn borrow_mut(&mut self) -> Option<ManagedRefMut<T>>
Takes an exclusive handle to the value.
Always None for shared and unclaimed handles.
Sourcepub fn lazy(&mut self) -> Option<ManagedLazy<T>>
pub fn lazy(&mut self) -> Option<ManagedLazy<T>>
Takes an unclaimed handle to the value.
Always None for a shared handle. See
ManagedValue::lazy_immutable.
Sourcepub unsafe fn lazy_immutable(&self) -> ManagedLazy<T>
pub unsafe fn lazy_immutable(&self) -> ManagedLazy<T>
ManagedValue::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_dynamic(self) -> Result<DynamicManagedValue, Self>
pub fn into_dynamic(self) -> Result<DynamicManagedValue, Self>
Erases the type, giving self back when an owned value cannot be moved
into its own allocation.