Skip to main content

export_trait

Macro export_trait 

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

Generate C ABI exports (trait_call, trait_free) for a trait function.

The target function must have signature: fn(&[serde_json::Value]) -> serde_json::Value

§Usage

mod my_trait;
plugin_api::export_trait!(my_trait::handler);

This generates:

  • trait_call(json_ptr, json_len, out_len) -> *mut u8
  • trait_free(ptr, len)

The caller (kernel’s dylib_loader) passes JSON-serialized args as bytes, receives JSON-serialized result as bytes, and frees the buffer afterward.