Skip to main content

plugin

Attribute Macro plugin 

Source
#[plugin]
Expand description

Export a Router constructor as a REPE C-ABI plugin.

(Every repe type below is linked by URL rather than by path: this is a proc-macro crate, and it does not — cannot — depend on repe.)

Applied to a zero-argument function returning a Router, this emits the five symbols a REPE host resolves after dlopen — repe_plugin_interface_version, repe_plugin_info, repe_plugin_init, repe_plugin_shutdown, and repe_plugin_call — each delegating to a repe::plugin::PluginRuntime built from your function. See repe::plugin for the ABI contract and the deployment requirements that come with it.

ⓘ
// Cargo.toml: [lib] crate-type = ["cdylib"]
use repe::server::Router;

#[repe::plugin(root = "/calculator")]
fn build() -> Router {
    Router::new().with_typed("/calculator/add", |(a, b): (i64, i64)| Ok(a + b))
}

§Arguments

  • root (required) — the RPC path prefix this plugin claims, reported to the host as repe_plugin_data::root_path. Must be an absolute JSON Pointer prefix: leading /, no trailing /.
  • name — defaults to the crate’s CARGO_PKG_NAME.
  • version — defaults to the crate’s CARGO_PKG_VERSION.

Both defaults exist so the plugin’s identity is not restated beside the manifest that already carries it, and so it cannot drift from it.

The annotated function is left in place and stays callable, which is what lets the same router be exercised by ordinary in-process tests.