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.
- Arity
Str1 - Marker for a closure whose sole parameter is a borrowed
&str. - Host
Error - Why a registered host function failed.
- Host
Registry - The table of Rust closures a script’s
hostblocks bind to.
Enums§
- Host
Bind Error - Why a script’s
hostblocks could not be bound to aHostRegistry. - Host
Type - The type kinds that can cross the host boundary.
- Value
- A dynamically-typed value passed across the host/script boundary.
Traits§
- From
Host Value - Extracts a Rust argument from a
Valuefor a registered host closure. - Into
Host Fn - Adapts a Rust closure into a registered host function.
- Into
Host Result - What a registered host closure returns: a value, or an error to raise in the script that called it.
- Into
Host Value - Converts a host closure’s return value into a
Value.
Functions§
- describe_
value - Names the shape of a host
Valuefor an argument-mismatch report. - holds_
enum - Whether a host
Valueis 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
argsinto the matching register ofarg_registers, with the register file as the only roots: what a host does between runs. - marshal_
value - Allocates
vinto candela’s heap pools and returns the value to store. - unmarshal_
value - Reads a runtime
Databack into a hostValue, recursively for arrays, maps, structs and enums. Arrays, structs and enums live in the shared object pool; structs are surfaced as string-keyedValue::Maps using their declared field names, and an enum becomes aValue::Enumnaming the variant it holds. Map keys that are not strings are skipped. - value_
matches_ type - Whether a host
Valuesatisfies a declared parameter type.
Type Aliases§
- Host
Dispatch - The type-erased closure the VM dispatches a
hostcall to.