#[repr(C)]pub struct PluginApi {Show 17 fields
pub abi_version: u32,
pub struct_size: u32,
pub free_string: FreeStringFn,
pub register_tool: Option<extern "C" fn(schema: *const StableToolSchema, execute_fn: ToolExecuteFn, poll_fn: ToolPollFn, cancel_fn: ToolCancelFn, destroy_fn: ToolDestroyFn, plugin_free_string: FreeStringFn) -> i32>,
pub register_command: Option<extern "C" fn(name: StbStringRef, description: StbStringRef, handler: CommandHandlerFn) -> i32>,
pub register_shortcut: Option<extern "C" fn(key: StbStringRef, description: StbStringRef) -> i32>,
pub register_flag: Option<extern "C" fn(name: StbStringRef, description: StbStringRef) -> i32>,
pub register_provider: Option<extern "C" fn(provider_id: StbStringRef, base_url: StbStringRef, api_style: StbStringRef, request_fn: ProviderRequestFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>,
pub register_message_renderer: Option<extern "C" fn(name: StbStringRef, render_fn: RenderFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>,
pub register_markdown_transformer: Option<extern "C" fn(name: StbStringRef, render_fn: RenderFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>,
pub register_entry_renderer: Option<extern "C" fn(name: StbStringRef, render_fn: RenderFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>,
pub register_event_handler: Option<extern "C" fn(tag: EventTag, handler: EventHandlerFn, user_data: *mut c_void) -> i32>,
pub register_resources_discover: Option<extern "C" fn(handler: ResourcesDiscoverFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>,
pub runtime_action: RuntimeActionFn,
pub dispatch_event: Option<extern "C" fn(event: StablePluginEvent, user_data: *mut c_void) -> i32>,
pub user_data: *mut c_void,
pub declare: Option<extern "C" fn(json: StbStringRef) -> i32>,
}Expand description
The unified host-provided API struct. The first two fields (abi_version
and struct_size) are contract-identity markers that survive future
signature changes: a plugin reads them from the pointer before anything
else, so even if the entrypoint arity changes, the version check remains
robust.
This struct folds in v3’s declare slot (previously in PluginApiVt3Ext),
so there’s no side block — one struct, one entrypoint, forever.
Fields§
§abi_version: u32Contract identity. First field so a plugin can validate before reading anything else, independent of the entrypoint arity.
struct_size: u32sizeof(PluginApi) as the host built it. Lets a plugin detect a host
that predates slots it wants (host_struct_size < plugin’s expected
offset). Future hosts may grow this struct; old plugins check
struct_size before accessing new fields.
free_string: FreeStringFnHost’s free_string — the plugin calls this for every StbString it
receives from the host (outputs of actions, event payloads, inputs to
execute). Never null.
register_tool: Option<extern "C" fn(schema: *const StableToolSchema, execute_fn: ToolExecuteFn, poll_fn: ToolPollFn, cancel_fn: ToolCancelFn, destroy_fn: ToolDestroyFn, plugin_free_string: FreeStringFn) -> i32>§register_command: Option<extern "C" fn(name: StbStringRef, description: StbStringRef, handler: CommandHandlerFn) -> i32>§register_shortcut: Option<extern "C" fn(key: StbStringRef, description: StbStringRef) -> i32>§register_flag: Option<extern "C" fn(name: StbStringRef, description: StbStringRef) -> i32>§register_provider: Option<extern "C" fn(provider_id: StbStringRef, base_url: StbStringRef, api_style: StbStringRef, request_fn: ProviderRequestFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>§register_message_renderer: Option<extern "C" fn(name: StbStringRef, render_fn: RenderFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>§register_markdown_transformer: Option<extern "C" fn(name: StbStringRef, render_fn: RenderFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>§register_entry_renderer: Option<extern "C" fn(name: StbStringRef, render_fn: RenderFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>§register_event_handler: Option<extern "C" fn(tag: EventTag, handler: EventHandlerFn, user_data: *mut c_void) -> i32>§register_resources_discover: Option<extern "C" fn(handler: ResourcesDiscoverFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>§runtime_action: RuntimeActionFn§dispatch_event: Option<extern "C" fn(event: StablePluginEvent, user_data: *mut c_void) -> i32>§user_data: *mut c_void§declare: Option<extern "C" fn(json: StbStringRef) -> i32>Declare this plugin’s host-side preferences as a JSON object, e.g.
{"priority":60,"platforms":["linux","macos"]}. Nullable: host does
not support declarations yet (plugin skips the call; host applies
defaults: priority 100, all platforms).