Skip to main content

Module abi

Module abi 

Source
Expand description

The plugin C ABI (version 2 for WEIRDNET): the SDK’s own abi.rs. Version 1 has the same layout, so a host table built from these types serves either. The Weirdnet plugin C ABI, version 2. Shared verbatim by hosts and plugins.

Version 2 has the same layout and calling convention as version 1 of the SDK this one descends from; it differs in its symbol names and version number, so a host knows which SDK a library was built against and never mistakes one for the other.

A plugin is a shared library (.so, .dylib, .dll) exporting three symbols:

symbolsignaturemeaning
weirdnet_plugin_abiextern "C" fn() -> u32the ABI version it was built for (ABI_VERSION)
weirdnet_plugin_infoextern "C" fn() -> WnStrstatic UTF-8 JSON: {"sdk": "0.1.0", "lang": "rust"} (and "kind" from plugin!(run, kind = "…"))
weirdnet_plugin_rununsafe extern "C" fn(*const WnHost) -> i32run once; RUN_OK or an error code

Everything else goes through the host table WnHost: call(ctx, method, request, out) takes a method name and a JSON request and fills out with a JSON reply that the plugin returns with free. Memory never crosses allocators: the host frees what it allocates, and the plugin only lends (WnStr) what it owns.

Compatibility: the layout of these types and the three symbols never change within an ABI version. New host methods may be added at any time (methods lists them); a plugin asking for a method the host does not know gets an error, never a crash. A host refuses plugins whose weirdnet_plugin_abi is not one it supports.

Structs§

WnBuf
Bytes owned by the host; give them back with WnHost::free.
WnHost
What the host gives a plugin for one run.
WnStr
Borrowed UTF-8 bytes.

Constants§

ABI_VERSION
The ABI version this file describes.
CALL_ERROR
call failed and out holds the error message (UTF-8, not JSON).
CALL_OK
call succeeded and out holds the JSON reply.
RUN_ERROR
The run failed with an error (sent to the host with the error method).
RUN_OK
weirdnet_plugin_run finished; the result (or error) was handed to the host.
RUN_PANIC
The plugin panicked (the panic was caught; its message was sent with error).
SYM_ABI
Exported symbol names (NUL-terminated for dlsym).
SYM_INFO
SYM_RUN

Type Aliases§

HostCall
Calls a host method: method name, request JSON; fills out; returns CALL_OK or CALL_ERROR.
HostFree
Frees a buffer the host filled.
PluginAbi
PluginInfo
PluginRun