Skip to main content

Module abi

Module abi 

Source
Expand description

The runtime plugin ABI: what a native (dylib) or WASM plugin exports, and the one description, PluginAbi, both loaders decode it into.

Rust’s own ABI is unstable, so nothing Rust-specific crosses the boundary: a runtime plugin exchanges UTF-8 text with its host and nothing else. What it may contribute is deliberately small (CapabilityKind):

kindinputoutput
transformplain textplain text
highlighterplain textstyle spans, one START END STYLE per line
fence-markupa Markdown fence’s coderich console markup
fence-ansia Markdown fence’s codetext with ANSI SGR styling

Every call also receives the width available, in cells. The host sanitizes every output before it reaches a console: terminal controls are made visible, and only fence-ansi keeps SGR styling, through the same sanitizer rich view uses.

Native plugins export one C function, DYLIB_ENTRY_SYMBOL, returning a PluginDescriptor. Write it with export_dylib_plugin! rather than by hand. WASM plugins export a manifest in the text form of PluginAbi (see PluginAbi::to_manifest) and a call function; the exports are listed under wasm.

Versioning: ABI_MAJOR changes with any incompatible change, and a host refuses a plugin built for another major. A newer minor loads when it uses nothing the host lacks (an unknown capability kind is refused).

Modules§

wasm
The export names of a WASM plugin. A module must export all of them and import nothing:

Structs§

AbiCapability
One capability a runtime plugin declares.
AbiCapabilityEntry
One capability in a PluginDescriptor: a CapabilityKind::code and a name.
AbiOutput
Bytes a plugin allocated and hands to the host, which gives them back through PluginVTable::free (the plugin’s allocator frees them).
AbiStr
A borrowed UTF-8 string: len bytes at ptr.
Exports
A native plugin’s description and functions, for export_dylib_plugin!.
PluginAbi
A runtime plugin’s self-description, decoded from a native plugin’s PluginDescriptor or a WASM plugin’s manifest. Both loaders produce this one type, and one host adapter turns it into registry capabilities.
PluginDescriptor
What DYLIB_ENTRY_SYMBOL returns. abi_major and abi_minor come first and stay first in every version, so a host can read them before trusting the rest of the layout.
PluginFunctions
A PluginVTable that read_descriptor checked: neither is null.
PluginVTable
The functions a native plugin provides. Each is nullable here, because a non-nullable Rust function pointer holding null is undefined behaviour before it is ever called; read_descriptor refuses a null one.

Enums§

AbiError
Why a runtime plugin’s description was refused.
CapabilityKind
What a runtime plugin can contribute. The subset is chosen so that every contribution is text in and text out, which the host can check.

Constants§

ABI_MAJOR
The ABI’s major version. A host refuses a plugin with another.
ABI_MINOR
The ABI’s minor version: additions a host of the same major may lack.
DYLIB_ENTRY_SYMBOL
The function a native plugin exports: extern "C" fn() -> *const PluginDescriptor.
MAX_CAPABILITIES
The most capabilities one runtime plugin may declare.
MAX_FIELD_LEN
The longest version or description string accepted, in bytes.
STATUS_ERROR
The call failed; the output is an error message.
STATUS_OK
The call succeeded; the output is the result.

Functions§

free_output⚠
Free an AbiOutput made by AbiOutput::from_string.
read_descriptor⚠
Decode a descriptor a native plugin’s entry point returned.

Type Aliases§

AbiCallFn
Run capability capability (an index into the descriptor’s capabilities) on input, with width cells available, writing the output to output and returning STATUS_OK or STATUS_ERROR.
AbiFreeFn
Free an output a call returned.
ExportFn
One capability’s implementation: the input and the width in cells, to the output or an error message.