Skip to main content

PluginApiVt

Struct PluginApiVt 

Source
#[repr(C)]
pub struct PluginApiVt {
Show 14 fields 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,
}
Expand description

The ABI v2 host-provided vtable, passed to rpi_plugin_register_v2 as a *const.

The plugin reads it during register and may copy fn pointers it needs (the struct is POD/Copy). Every slot is nullable: a null fn pointer means the host does not support that capability yet — the plugin MUST null-check before calling and degrade gracefully. This keeps the vtable forward- compatible across rpi versions without re-ABI bumps within one RPI_PLUGIN_ABI_VERSION.

user_data is the host’s opaque context, passed back to every host-provided fn (so the host can recover its session/harness state). The plugin stores it and passes it through unchanged.

Fields§

§free_string: FreeStringFn

Host’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 a tool. schema + the four lifecycle fns + the plugin’s own free_string (for the StbStrings in schema). Returns 0 on success. Nullable: host not yet wired for tool registration.

§register_command: Option<extern "C" fn(name: StbStringRef, description: StbStringRef, handler: CommandHandlerFn) -> i32>

Register a slash command. Nullable.

§register_shortcut: Option<extern "C" fn(key: StbStringRef, description: StbStringRef) -> i32>

Register a keyboard shortcut. Nullable.

§register_flag: Option<extern "C" fn(name: StbStringRef, description: StbStringRef) -> i32>

Register a CLI flag using its bare name (without leading --). The parsed value is read later with RuntimeActionId::GetCliFlag. Nullable.

§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 a custom provider. The host stores provider_id/base_url/ api_style + the plugin’s request_fn + the plugin’s own plugin_free_string (the out StbString request_fn produces is plugin-owned and the host must reclaim it — same ownership rule as register_resources_discover) + the plugin’s user_data (which request_fn receives back unmodified on every call). Nullable (B5c).

§register_message_renderer: Option<extern "C" fn(name: StbStringRef, render_fn: RenderFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>

Register a message renderer. plugin_free_string reclaims the out StbString render_fn produces; user_data is passed back to it on every render call. Nullable; interactive TUI consumption accepts the host JSON component envelope (text/lines).

§register_markdown_transformer: Option<extern "C" fn(name: StbStringRef, render_fn: RenderFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>

Register a markdown transformer. Same ownership shape as register_message_renderer. Nullable; markdown output is chained in assistant rendering.

§register_entry_renderer: Option<extern "C" fn(name: StbStringRef, render_fn: RenderFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>

Register an entry renderer. Same ownership shape as register_message_renderer. Nullable; interactive TUI consumption accepts the host JSON component envelope (text/lines).

§register_event_handler: Option<extern "C" fn(tag: EventTag, handler: EventHandlerFn, user_data: *mut c_void) -> i32>

Subscribe a handler to one event tag. Nullable: host not yet wiring events. The host dispatches StablePluginEvents of that tag to the handler (catch_unwind-wrapped).

§register_resources_discover: Option<extern "C" fn(handler: ResourcesDiscoverFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>

Register a resources_discover handler (B5b). The host stores handler

  • the plugin’s own plugin_free_string (the out StbString the handler produces is plugin-owned and the host must reclaim it) + user_data. On discovery (startup/reload) the host fans the event to every registered handler in order, concatenating their returned {skillPaths, promptPaths, themePaths} (errors per-handler do NOT abort the fan-out). Nullable: a host without the resources-discover path leaves this null and the plugin must degrade (no dynamic resource contribution).
§runtime_action: RuntimeActionFn

Invoke a host runtime action. See RuntimeActionId / RuntimeActionFn. Always present; a host without an action bridge installs a nonzero-returning stub so plugins can degrade gracefully.

§dispatch_event: Option<extern "C" fn(event: StablePluginEvent, user_data: *mut c_void) -> i32>

Emit an event upstream (e.g. a tool announcing a custom UI event). The host forwards to interested subscribers. Ownership of the event’s StbStrings passes to the host (freed via free_string). Nullable.

§user_data: *mut c_void

The host’s opaque context, passed through to every host-provided fn. The plugin stores this and hands it back unmodified on each call.

Trait Implementations§

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.