Expand description
FFI-safe dynamic plugin loading.
Plugins compiled as shared libraries (.so, .dylib, .dll) export a
registration function with the PLUGIN_REGISTER_SYMBOL name. The host
loads them at startup via load_plugins_from_dir and calls the
registration function to populate the PluginRegistryBuilder.
§Safety
Dynamic plugin loading is inherently unsafe — the host trusts that the loaded library is ABI-compatible. Protections:
- API version check: before calling
register, the host verifies the plugin’s reported API version matchesAPI_VERSION. catch_unwind: registration calls are wrapped to prevent panics from unwinding across the FFI boundary.- Directory permissions: a warning is logged if the plugin directory is world-writable.
Enums§
- Plugin
Load Result - Outcome of loading a single plugin library.
Constants§
- API_
VERSION - Current API version. Plugins must return this from their
PLUGIN_API_VERSION_SYMBOLexport to be accepted. - PLUGIN_
API_ VERSION_ SYMBOL - Symbol name for the plugin API version function.
- PLUGIN_
REGISTER_ SYMBOL - Symbol name for the plugin registration function.
Functions§
- load_
plugins_ from_ dir - Load all plugin shared libraries from
dirand register them withbuilder.
Type Aliases§
- ApiVersion
Fn - Type signature for the optional API version query.
- Register
Plugin Fn - Type signature for the plugin registration entry point.