Skip to main content

Module script_fn

Module script_fn 

Source
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.
CallScratch
The two buffers one call needs: the arguments going in, and the commands coming out.
ScriptField
One field of a ScriptStruct.
ScriptFn
One native function, in terms every script host understands.
ScriptFnBuilder
Builder for a typed ScriptFn. Start it with ScriptFn::new.
ScriptFnCx
The call a ScriptFn body receives: its arguments, and the sink it emits commands into.
ScriptFnRegistry
The app-wide registration channel every script host drains.
ScriptFnStore
The functions a host registered, kept so it can put them back.
ScriptParam
One declared parameter: the name a doc or an editor shows, and its type.
ScriptPrelude
Source a plugin ships in a script language, compiled ahead of the app’s own program.
ScriptSig
The declared signature of a ScriptFn.
ScriptStruct
A struct parameter: a name, and fields in declaration order, each with the value it starts with.
ScriptTyError
Why a type spelling is not one ScriptTy reads.

Enums§

ScriptNs
Where a function lives in the script’s name space.
ScriptTy
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§

IntoScriptFn
Adapts a plain Rust closure into the body and signature of a ScriptFn.
ScriptFnAppExt
Register script functions on an App.
ScriptRet
What a ScriptFn::from_fn closure may return: a value, or a Result whose error message reaches the script.
ScriptType
A Rust type ScriptFn::from_fn can carry across the script boundary.

Functions§

with_call_scratch
Borrow this thread’s cleared CallScratch for the length of one call.

Type Aliases§

ScriptFnBody
The callable half of a ScriptFn. Shared so one description binds into several hosts, Send + Sync so it runs on any of their threads.
ScriptResult
What a ScriptFn body hands back: a value, or the message to raise in the script that called it.