Skip to main content

PluginApi

Struct PluginApi 

Source
#[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: u32

Contract identity. First field so a plugin can validate before reading anything else, independent of the entrypoint arity.

§struct_size: u32

sizeof(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: 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_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).

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.