pub fn run<A: IVm>(
module: Module<A>,
export: &str,
action: Action<A>,
) -> Result<String, RunError<A>>Expand description
Evaluates a module once, selects one of its exports, reads or calls it, and renders that one value as JSON. Nothing else in the export object is called or serialized.
module is the shape generated modules expose, Module<A>, read
through exports: the object of all exports, or the value the module
threw, a module answering anything else refused as a thrown TypeError.
A module holding a function bounds A on IStaticFunction, which
naive implements.
export is looked up among the object’s own properties by presence,
not by value: an export holding undefined is found, and reading it
then fails as JsonError::Undefined. default is one name among
them, with no fallback to it: a module without one answers
NoExport("default") for it.
A call converts a clone of the selected value with
Function::try_from, whose own error is a fresh TypeError, so that
RunError::NotCallable holds the value the caller tried to call. It
does not go through Any::call, where a value that is not a function
would be a thrown TypeError, indistinguishable from the program
throwing.