Skip to main content

Module script

Module script 

Source
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 (E0505 otherwise);
  • 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§

BoundaryError
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.
ScriptBuilder
Configures a script before it is loaded. Grants have the names and meaning of the CLI’s flags.
ScriptVersion
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 Serialize values. The arity is a constant, so binding a function can check it before any call is made.
EffectFn
A Rust closure that can be given to ScriptBuilder::effect: as PureFn, returning Result<R, E> where E explains the failure.
PureFn
A Rust closure that can be given to ScriptBuilder::pure: up to six arguments that Deserialize, and a result that Serializes.