Expand description
The host-neutral native-function description (ScriptFn) and the
app-wide channel plugins register them through.
One description of a native function every script host can bind.
A ScriptFn says what a function is called, what it takes, what it
returns, and which namespace it lives in. Each
host implements ScriptHost::register_script_fn
once and gets every function an app, a plugin, the C ABI, or the Rust SDK
describes.
The registration channel is ScriptFnRegistry, a resource on the main
world. A Plugin pushes into it through
ScriptFnAppExt::add_script_fn; the generic script plugin drains it into
the host it is about to load, then seals it. This is Lumen’s counterpart of
QML’s QQmlContext::setContextProperty: one embedder-facing surface, seen
by every scripting context the app runs.
Structs§
- Arity0
- Marker for a closure that takes no arguments.
- Call
Scratch - The two buffers one call needs: the arguments going in, and the commands coming out.
- Script
Field - One field of a
ScriptStruct. - Script
Fn - One native function, in terms every script host understands.
- Script
FnBuilder - Builder for a typed
ScriptFn. Start it withScriptFn::new. - Script
FnCx - The call a
ScriptFnbody receives: its arguments, and the sink it emits commands into. - Script
FnRegistry - The app-wide registration channel every script host drains.
- Script
FnStore - The functions a host registered, kept so it can put them back.
- Script
Param - One declared parameter: the name a doc or an editor shows, and its type.
- Script
Prelude - Source a plugin ships in a script language, compiled ahead of the app’s own program.
- Script
Sig - The declared signature of a
ScriptFn. - Script
Struct - A struct parameter: a name, and fields in declaration order, each with the value it starts with.
- Script
TyError - Why a type spelling is not one
ScriptTyreads.
Enums§
- Script
Ns - Where a function lives in the script’s name space.
- Script
Ty - The shape of one parameter or return value.
Constants§
- MAX_
VARIADIC_ ARITY - How many arguments a variadic signature is bound for on a host that dispatches by arity. Rhai has no native variadics, so it takes one registration per count up to this bound.
Traits§
- Into
Script Fn - Adapts a plain Rust closure into the body and signature of a
ScriptFn. - Script
FnApp Ext - Register script functions on an
App. - Script
Ret - What a
ScriptFn::from_fnclosure may return: a value, or aResultwhose error message reaches the script. - Script
Type - A Rust type
ScriptFn::from_fncan carry across the script boundary.
Functions§
- with_
call_ scratch - Borrow this thread’s cleared
CallScratchfor the length of one call.
Type Aliases§
- Script
FnBody - The callable half of a
ScriptFn. Shared so one description binds into several hosts,Send + Syncso it runs on any of their threads. - Script
Result - What a
ScriptFnbody hands back: a value, or the message to raise in the script that called it.