Skip to main content

export_dylib_plugin

Macro export_dylib_plugin 

Source
macro_rules! export_dylib_plugin {
    ($exports:expr) => { ... };
}
Expand description

Export a native plugin from a cdylib crate.

The argument is a function (or non-capturing closure) returning Exports. The macro defines the rich_plugin_entry symbol; the crate needs crate-type = ["cdylib"] and no unsafe code of its own.

use rich_plugin_api::abi::Exports;

fn upper(input: &str, _width: u32) -> Result<String, String> {
    Ok(input.to_uppercase())
}

rich_plugin_api::export_dylib_plugin!(|| {
    Exports::new("shout", "0.1.0")
        .description("Upper-cases text")
        .transform("upper", upper)
});