Expand description
The embedding API (D33): a loaded script a Rust host can call.
A Script is loaded once — lexed, parsed, analysed and evaluated — and then
called as often as the host likes, from as many threads as it likes. Every
guarantee the CLI gives holds here too, because loading goes through the same
loader, analysis and capability model:
- hermetic by default: with no grants, loading proves statically that the
script reads no file, variable or clock (
E0505otherwise); - a budget per call, in steps and bytes, never in time (
E0325/E0326); - constant memory per call: each call runs in its own interpreter, whose environments are released when it returns;
- a checked boundary: a value Aura cannot hold exactly is refused at the
door (
E0005), and a result of the wrong shape names the path (E0006).
What a call costs: an Arc clone of the shared method registry, a fresh
interpreter around it, and the conversion of arguments and result. Parsing,
analysis and module evaluation are never repeated.
Structs§
- Boundary
Error - A host value Aura cannot hold exactly. Refused rather than coerced: an
integer wrapped, or a NaN turned into
null, would be a different input than the host meant to give. - Error
- Everything that can go wrong loading or calling a script. It carries the same reports the CLI prints: a code, a position when there is one, and the help line.
- Function
- A bound function: the checks are done, so a call only converts, runs and converts back.
- Script
- A loaded script.
Send + Sync: one instance serves every thread, and a call takes&self. - Script
Builder - Configures a script before it is loaded. Grants have the names and meaning of the CLI’s flags.
- Script
Version - Which version of a script is serving (D36 §8): the generation counts successful loads from 1, and the hash covers every file the load read.
Traits§
- Args
- The arguments of a call: a tuple of
Serializevalues. The arity is a constant, so binding a function can check it before any call is made. - Effect
Fn - A Rust closure that can be given to
ScriptBuilder::effect: asPureFn, returningResult<R, E>whereEexplains the failure. - PureFn
- A Rust closure that can be given to
ScriptBuilder::pure: up to six arguments thatDeserialize, and a result thatSerializes.