Trait CustomTypes

Source
pub trait CustomTypes<S: System<Self>>: 'static + Sized {
    type NativeValue: 'static + GetType + Debug;
    type Intermediate: 'static + Send + From<SimpleValue>;
    type EntityState: 'static + for<'gc, 'a> From<EntityKind<'gc, 'a, Self, S>>;
    type ProcessState: 'static + Unwindable + for<'gc, 'a> From<ProcessKind<'gc, 'a, Self, S>>;

    // Required method
    fn from_intermediate<'gc>(
        mc: &Mutation<'gc>,
        value: Self::Intermediate,
    ) -> Value<'gc, Self, S>;
}
Expand description

A collection of static settings for using custom native types.

Required Associated Types§

Source

type NativeValue: 'static + GetType + Debug

A native type that can be exposed directly to the VM as a value of type Value::Native. This could, for example, be used to allow a process to hold on to a file handle stored in a variable. For type checking, this is required to implement GetType, which can use a custom type enum. Native types have reference semantics in the vm.

Source

type Intermediate: 'static + Send + From<SimpleValue>

An intermediate type used to produce a Value for the System under async context. The reason this is needed is that Value can only be used during the lifetime of an associated Mutation handle, which cannot be extended into the larger lifetime required for async operations. Conversions are automatically performed from this type to Value via CustomTypes::from_intermediate.

Source

type EntityState: 'static + for<'gc, 'a> From<EntityKind<'gc, 'a, Self, S>>

Type used to represent an entity’s system-specific state. This should include any details outside of core process functionality (e.g., graphics, position, orientation). This type should be constructable from EntityKind, which is used to initialize a new entity in the runtime.

Source

type ProcessState: 'static + Unwindable + for<'gc, 'a> From<ProcessKind<'gc, 'a, Self, S>>

Type used to represent a process’s system-specific state. This should include any details outside of core process functionality (e.g., external script-locals). This type should be constructable from ProcessKind, which is used to initialize a new process in the runtime.

Required Methods§

Source

fn from_intermediate<'gc>( mc: &Mutation<'gc>, value: Self::Intermediate, ) -> Value<'gc, Self, S>

Converts a Value into a CustomTypes::Intermediate for use outside of gc context.

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§