Skip to main content

ScriptType

Trait ScriptType 

Source
pub trait ScriptType: Sized {
    // Required methods
    fn script_ty() -> ScriptTy;
    fn from_script_value(value: &ScriptValue) -> Self;
    fn into_script_value(self) -> ScriptValue;
}
Expand description

A Rust type ScriptFn::from_fn can carry across the script boundary.

Implemented for the scalars every host shares (i64, f64, bool, String), for (), and recursively for Vec<T> and HashMap<String, T>. The conversion into Rust is the same coercion the ScriptFnCx accessors apply, so an integer arrives where a float is declared and a missing argument reads as the type’s empty value.

Required Methods§

Source

fn script_ty() -> ScriptTy

The declared type a host binds this parameter or return slot as.

Source

fn from_script_value(value: &ScriptValue) -> Self

Read one argument.

Source

fn into_script_value(self) -> ScriptValue

Hand one value back to the script.

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.

Implementations on Foreign Types§

Source§

impl ScriptType for bool

Source§

impl ScriptType for f64

Source§

impl ScriptType for i64

Source§

impl ScriptType for ()

Source§

impl ScriptType for String

Source§

impl<T: ScriptType> ScriptType for Vec<T>

Source§

impl<T: ScriptType> ScriptType for HashMap<String, T>

Implementors§