Alternera. PluginWasmFramework. Frame
(alternera_plugin_wasm_framework v0.9.0)
Copy Markdown
View Source
The frames of guest interface version 0 (c_src/alternera_guest.h), the
host's side. A field is a 32-bit little-endian length and that many
bytes.
- The request frame
alternera_rungets: the source as a field, then the env, a JSON object, to the end (request/2). Bodies are not in it: the guest reads them throughalternera.body_read. - The reply frame it answers: a status byte, a flags byte and four
fields,
a,b,candoutputs(decode_reply/1), whose meaning depends on the status. - A host call's answer:
0and the operation's JSON answer, or1and two fields, the error's type and its message (the runtime writes it from what the host function gave). - What
alternera_checkanswers: a JSON array of{"line", "message"}(decode_check/1).
JSON objects in a returned value or in outputs are decoded as
Jason.OrderedObject, keeping the order the script built them in, as
Script's ordered JSON does.
Summary
Types
The named values a script set in outputs: name to JSON value.
A returned value: the raw bytes of a string, or a JSON value.
Functions
What alternera_check answered: :ok, or the problems as {line, message} (line nil when the guest named none).
text as JSON, objects in their order.
A reply frame read back, or {:error, why} for one that is not well formed.
The request frame for source and env (a map JSON can encode).
Types
The named values a script set in outputs: name to JSON value.
@type reply() :: {:returned, value(), String.t() | nil, outputs()} | {:nothing, outputs()} | {:failed, String.t(), String.t(), pos_integer() | nil, outputs()} | {:script_error, String.t(), pos_integer() | nil, outputs()} | :allocation_refused | {:invalid_result, String.t(), outputs()} | {:host_error, String.t(), String.t(), outputs()}
A returned value: the raw bytes of a string, or a JSON value.
Functions
@spec decode_check(binary()) :: :ok | {:error, [{pos_integer() | nil, String.t()}]}
What alternera_check answered: :ok, or the problems as {line, message} (line nil when the guest named none).
text as JSON, objects in their order.
A reply frame read back, or {:error, why} for one that is not well formed.
The request frame for source and env (a map JSON can encode).