[][src]Function message_plugins::construct_plugin

pub fn construct_plugin<T>(
    path: impl AsRef<OsStr>
) -> Result<Box<dyn Plugin<T>>, Error>

A default for construct_plugin_with_constructor, which will call a function named plugin_constructor. The constructor function is the only function where you need to dirty your hands with extern "C". Its sole purpose is to insert your boxed plugin into a pointer. I suggest writing a constructor of the style:

#[no_mangle]
unsafe extern "C" fn plugin_constructor(ptr: *mut Box<dyn Plugin<YourMessageType>>) {
    let plugin = Box::new(YourPlugin::new());
    insert_instace(ptr, plugin);
}