Skip to main content

Module dynamic

Module dynamic 

Source
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 matches API_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§

PluginLoadResult
Outcome of loading a single plugin library.

Constants§

API_VERSION
Current API version. Plugins must return this from their PLUGIN_API_VERSION_SYMBOL export 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 dir and register them with builder.

Type Aliases§

ApiVersionFn
Type signature for the optional API version query.
RegisterPluginFn
Type signature for the plugin registration entry point.