Skip to main content

Module embed

Module embed 

Source
Expand description

Host/script value marshalling for candela’s embedding API.

These types cross the boundary between a Rust host and a running candela script: Value is the dynamically-typed carrier, HostType describes the shapes that can cross, the FromHostValue/IntoHostValue/ IntoHostResult/IntoHostFn traits adapt Rust closures into registered host functions, HostError is how one of them fails, HostRegistry holds the closures a script’s host blocks bind to, and marshal_value/unmarshal_value convert between Value and the VM’s NaN-boxed Data. They carry no compiler state and the VM depends on them, so they live in the VM-only crate. The Engine/Program embedding surface (which compiles and drives scripts) lives in the candela crate on top.

Structs§

Arity0
Marker for a nullary closure.
ArityStr1
Marker for a closure whose sole parameter is a borrowed &str.
HostError
Why a registered host function failed.
HostRegistry
The table of Rust closures a script’s host blocks bind to.

Enums§

HostBindError
Why a script’s host blocks could not be bound to a HostRegistry.
HostType
The type kinds that can cross the host boundary.
Value
A dynamically-typed value passed across the host/script boundary.

Traits§

FromHostValue
Extracts a Rust argument from a Value for a registered host closure.
IntoHostFn
Adapts a Rust closure into a registered host function.
IntoHostResult
What a registered host closure returns: a value, or an error to raise in the script that called it.
IntoHostValue
Converts a host closure’s return value into a Value.

Functions§

describe_value
Names the shape of a host Value for an argument-mismatch report.
holds_enum
Whether a host Value is an enum, or carries one inside it.
is_host_callable_type
Whether a declared parameter type can be filled from a host Value.
marshal_args
Writes each of args into the matching register of arg_registers, with the register file as the only roots: what a host does between runs.
marshal_value
Allocates v into candela’s heap pools and returns the value to store.
unmarshal_value
Reads a runtime Data back into a host Value, recursively for arrays, maps, structs and enums. Arrays, structs and enums live in the shared object pool; structs are surfaced as string-keyed Value::Maps using their declared field names, and an enum becomes a Value::Enum naming the variant it holds. Map keys that are not strings are skipped.
value_matches_type
Whether a host Value satisfies a declared parameter type.

Type Aliases§

HostDispatch
The type-erased closure the VM dispatches a host call to.