rune::runtime

Trait UnsafeFromValue

Source
pub trait UnsafeFromValue: Sized {
    type Output: 'static;
    type Guard: 'static;

    // Required methods
    fn unsafe_from_value(value: Value) -> VmResult<(Self::Output, Self::Guard)>;
    unsafe fn unsafe_coerce(output: Self::Output) -> Self;
}
๐Ÿ‘ŽDeprecated: Rune: Implementing this trait will no longer work. Use UnsafeToRef and UnsafeToMut instead.
Expand description

A potentially unsafe conversion for value conversion.

This trait is used to convert values to references, which can be safely used while an external function call is used. That sort of use is safe because we hold onto the guard returned by the conversion during external function calls.

Required Associated Typesยง

Source

type Output: 'static

๐Ÿ‘ŽDeprecated: Rune: Implementing this trait will no longer work. Use UnsafeToRef and UnsafeToMut instead.

The output type from the unsafe coercion.

Source

type Guard: 'static

๐Ÿ‘ŽDeprecated: Rune: Implementing this trait will no longer work. Use UnsafeToRef and UnsafeToMut instead.

The raw guard returned.

Must only be dropped after the value returned from this function is no longer live.

Required Methodsยง

Source

fn unsafe_from_value(value: Value) -> VmResult<(Self::Output, Self::Guard)>

๐Ÿ‘ŽDeprecated: Rune: Implementing this trait will no longer work. Use UnsafeToRef and UnsafeToMut instead.

Convert the given reference using unsafe assumptions to a value.

ยงSafety

The return value of this function may only be used while a virtual machine is not being modified.

You must also make sure that the returned value does not outlive the guard.

Source

unsafe fn unsafe_coerce(output: Self::Output) -> Self

๐Ÿ‘ŽDeprecated: Rune: Implementing this trait will no longer work. Use UnsafeToRef and UnsafeToMut instead.

Coerce the output of an unsafe from value into the final output type.

ยงSafety

The return value of this function may only be used while a virtual machine is not being modified.

You must also make sure that the returned value does not outlive the guard.

Dyn Compatibilityยง

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementorsยง