Skip to main content

export_plugin

Macro export_plugin 

Source
macro_rules! export_plugin {
    ($register:path) => { ... };
}
Expand description

Make a crate a razeri plugin, in one line.

Name a function that registers what the crate provides:

ⓘ
use razeri_plugin_api::PluginRegistryBuilder;
use std::sync::Arc;

fn register(builder: &mut PluginRegistryBuilder) {
    builder.register_dialect(Arc::new(MyDb));
}

razeri_plugin_api::export_plugin!(register);

The crate can then reach razeri two ways, and the same line serves both:

  • Loaded from a plugin directory, built as a cdylib. The line exports how the library was built and the function razeri calls to register it. Razeri reads the first before it calls the second, and refuses a library built with another compiler or against other plugin crates.
  • Linked into a razeri you build, as an ordinary dependency. The line records register so the registry finds it at start-up, the same way it finds razeri’s own dialects.

Use it once per crate, at the top level of lib.rs.