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):
| kind | input | output |
|---|---|---|
transform | plain text | plain text |
highlighter | plain text | style spans, one START END STYLE per line |
fence-markup | a Markdown fence’s code | rich console markup |
fence-ansi | a Markdown fence’s code | text 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.
- AbiCapability
Entry - One capability in a
PluginDescriptor: aCapabilityKind::codeand 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:
lenbytes atptr. - Exports
- A native plugin’s description and functions, for
export_dylib_plugin!. - Plugin
Abi - A runtime plugin’s self-description, decoded from a native plugin’s
PluginDescriptoror a WASM plugin’s manifest. Both loaders produce this one type, and one host adapter turns it into registry capabilities. - Plugin
Descriptor - What
DYLIB_ENTRY_SYMBOLreturns.abi_majorandabi_minorcome first and stay first in every version, so a host can read them before trusting the rest of the layout. - Plugin
Functions - A
PluginVTablethatread_descriptorchecked: neither is null. - PluginV
Table - 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_descriptorrefuses a null one.
Enums§
- AbiError
- Why a runtime plugin’s description was refused.
- Capability
Kind - 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
AbiOutputmade byAbiOutput::from_string. - read_
descriptor ⚠ - Decode a descriptor a native plugin’s entry point returned.
Type Aliases§
- AbiCall
Fn - Run capability
capability(an index into the descriptor’s capabilities) oninput, withwidthcells available, writing the output tooutputand returningSTATUS_OKorSTATUS_ERROR. - AbiFree
Fn - Free an output a call returned.
- Export
Fn - One capability’s implementation: the input and the width in cells, to the output or an error message.