Skip to main content

ManagedValue

Enum ManagedValue 

Source
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>

Source

pub fn as_owned(&self) -> Option<&Managed<T>>

Returns the owned value, or None for any other role.

Source

pub fn as_mut_owned(&mut self) -> Option<&mut Managed<T>>

Returns the owned value mutably, or None for any other role.

Source

pub fn as_ref(&self) -> Option<&ManagedRef<T>>

Returns the shared handle, or None for any other role.

Source

pub fn as_mut_ref(&mut self) -> Option<&mut ManagedRef<T>>

Returns the shared handle mutably, or None for any other role.

Source

pub fn as_ref_mut(&self) -> Option<&ManagedRefMut<T>>

Returns the exclusive handle, or None for any other role.

Source

pub fn as_mut_ref_mut(&mut self) -> Option<&mut ManagedRefMut<T>>

Returns the exclusive handle mutably, or None for any other role.

Source

pub fn as_lazy(&self) -> Option<&ManagedLazy<T>>

Returns the unclaimed handle, or None for any other role.

Source

pub fn as_mut_lazy(&mut self) -> Option<&mut ManagedLazy<T>>

Returns the unclaimed handle mutably, or None for any other role.

Source

pub fn as_gc(&self) -> Option<&ManagedGc<T>>

Returns the garbage collected handle, or None for any other role.

Source

pub fn as_mut_gc(&mut self) -> Option<&mut ManagedGc<T>>

Returns the garbage collected handle mutably, or None for any other role.

Source

pub fn read(&self) -> Option<ValueReadAccess<'_, T>>

Guards the value for reading, whichever role holds it.

Source

pub fn write(&mut self) -> Option<ValueWriteAccess<'_, T>>

Guards the value for writing.

Always None for a shared handle.

Source

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.

Source

pub fn borrow_mut(&mut self) -> Option<ManagedRefMut<T>>

Takes an exclusive handle to the value.

Always None for shared and unclaimed handles.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<T> From<Managed<T>> for ManagedValue<T>

Source§

fn from(value: Managed<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ManagedGc<T>> for ManagedValue<T>

Source§

fn from(value: ManagedGc<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ManagedLazy<T>> for ManagedValue<T>

Source§

fn from(value: ManagedLazy<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ManagedRef<T>> for ManagedValue<T>

Source§

fn from(value: ManagedRef<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ManagedRefMut<T>> for ManagedValue<T>

Source§

fn from(value: ManagedRefMut<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> TryFrom<ManagedValue<T>> for ManagedGc<T>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(value: ManagedValue<T>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T> TryFrom<ManagedValue<T>> for Managed<T>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(value: ManagedValue<T>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T> TryFrom<ManagedValue<T>> for ManagedRef<T>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(value: ManagedValue<T>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T> TryFrom<ManagedValue<T>> for ManagedRefMut<T>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(value: ManagedValue<T>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T> TryFrom<ManagedValue<T>> for ManagedLazy<T>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(value: ManagedValue<T>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Finalize for T

Source§

unsafe fn finalize_raw(data: *mut ())

Drops the value stored at data in place. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.