Skip to main content

export_plugin

Macro export_plugin 

Source
macro_rules! export_plugin {
    ($ty:ty) => { ... };
    (
        $ty:ty,
        metadata: {
            plugin_id: $plugin_id:expr,
            display_name: $display_name:expr,
            version: $version:expr $(,)?
        } $(,)?
    ) => { ... };
}
Expand description

Define the entry points an out-of-tree plugin’s cdylib must export.

Pass the type that implements LinsightPlugin. The type must implement Default.

ABI v6: the factory returns a stabby dyn-ptr (stabby::dynptr!(Box<dyn LinsightPlugin + Send + Sync>)) annotated with #[stabby::export]. The host loads the symbol via StabbyLibrary::get_stabbied so the entire signature is validated by stabby’s reflection report.

A plain extern "C" fn() -> u32 named linsight_plugin_abi_version is emitted alongside so loaders can do a cheap version-compatibility short-circuit before paying the stabby cost. The factory symbol is linsight_plugin_v6 — renamed from linsight_plugin_v5 so a v5 plugin’s .so will fail symbol lookup at load time rather than silently exchanging vtables whose methods differ in unwind ABI (v6 switches the trait methods to extern "C-unwind" for panic isolation).

The metadata form emits an additional optional linsight_plugin_metadata_v1 symbol. The daemon uses it, when present, to look up per-plugin config before constructing or initializing the plugin. The one-argument form is kept for ABI-v6 plugins built before metadata existed; those plugins still load through the daemon’s probe fallback.