Skip to main content

DynamicManagedValue

Enum DynamicManagedValue 

Source
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

Source

pub fn as_owned(&self) -> Option<&DynamicManaged>

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

Source

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

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

Source

pub fn as_ref(&self) -> Option<&DynamicManagedRef>

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

Source

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

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

Source

pub fn as_ref_mut(&self) -> Option<&DynamicManagedRefMut>

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

Source

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

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

Source

pub fn as_lazy(&self) -> Option<&DynamicManagedLazy>

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

Source

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

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

Source

pub fn as_gc(&self) -> Option<&DynamicManagedGc>

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

Source

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

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

Source

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.

Source

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.

Source

pub fn borrow(&self) -> Option<DynamicManagedRef>

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

Takes an exclusive handle to the value.

Always None for shared and unclaimed handles.

Source

pub fn lazy(&self) -> Option<DynamicManagedLazy>

Takes an unclaimed handle to the value.

Always None for a shared handle. See DynamicManagedValue::lazy_immutable.

Source

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.

Source

pub fn into_typed<T>(self) -> Result<ManagedValue<T>, Self>

Recovers the typed value, giving self back on a type mismatch.

Trait Implementations§

Source§

impl From<DynamicManaged> for DynamicManagedValue

Source§

fn from(value: DynamicManaged) -> Self

Converts to this type from the input type.
Source§

impl From<DynamicManagedGc> for DynamicManagedValue

Source§

fn from(value: DynamicManagedGc) -> Self

Converts to this type from the input type.
Source§

impl From<DynamicManagedLazy> for DynamicManagedValue

Source§

fn from(value: DynamicManagedLazy) -> Self

Converts to this type from the input type.
Source§

impl From<DynamicManagedRef> for DynamicManagedValue

Source§

fn from(value: DynamicManagedRef) -> Self

Converts to this type from the input type.
Source§

impl From<DynamicManagedRefMut> for DynamicManagedValue

Source§

fn from(value: DynamicManagedRefMut) -> Self

Converts to this type from the input type.
Source§

impl TryFrom<DynamicManagedValue> for DynamicManagedGc

Source§

type Error = ()

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

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

Performs the conversion.
Source§

impl TryFrom<DynamicManagedValue> for DynamicManaged

Source§

type Error = ()

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

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

Performs the conversion.
Source§

impl TryFrom<DynamicManagedValue> for DynamicManagedRef

Source§

type Error = ()

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

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

Performs the conversion.
Source§

impl TryFrom<DynamicManagedValue> for DynamicManagedRefMut

Source§

type Error = ()

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

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

Performs the conversion.
Source§

impl TryFrom<DynamicManagedValue> for DynamicManagedLazy

Source§

type Error = ()

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

fn try_from(value: DynamicManagedValue) -> 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.