Skip to main content

Crate confium_macros

Crate confium_macros 

Source
Expand description

Proc-macros for Confium plugin authors.

Two macros reduce the per-plugin boilerplate that would otherwise be hand-rolled extern "C" symbols plus the plugin lifecycle hooks:

  • plugin_interface on an impl Trait for Type block emits the cfmp_<iface>_* FFI entry-point symbols from the trait methods.
  • export emits the plugin lifecycle symbols (cfmp_interface_version, cfmp_initialize, cfmp_finalize, cfmp_query_interfaces) plus the optional cfmp_metadata symbol when paired with plugin_metadata.

§Supported interfaces

The #[plugin_interface] macro recognizes the wire protocol for all Confium crypto interfaces at version 0: hash, cipher, aead, kdf, rng, signature, kem, and keyfmt. Each interface emits its canonical cfmp_<iface>_* symbol set, dispatching through the corresponding trait in confium_api::plugin.

Interfaces with complex parameter lists (signature, kem, keyfmt) automatically get #[allow(clippy::too_many_arguments)] on the affected symbols, since the parameter count is fixed by the C ABI.

Interface auto-discovery: every #[plugin_interface] attribute registers its (name, version) pair at link time via inventory. The #[export] macro iterates these registrations at runtime to populate cfmp_query_interfaces, so plugin authors do not need to repeat the interface list in #[export].

See TODO.roadmap/03-plugin-contract.md for the wire contract and crates/confium-api/src/ for the shared types the macros consume.

Attribute Macros§

export
Emits the plugin lifecycle symbols:
plugin_interface
Attribute macro that emits the cfmp_<iface>_* FFI entry-point symbols for the wire protocol named by name = "...".
plugin_metadata
Attribute used together with export to attach static registry metadata to the plugin. The strings are leaked at plugin load time and exposed through the generated cfmp_metadata symbol.