Skip to main content

plugin_api

Attribute Macro plugin_api 

Source
#[plugin_api]
Expand description

Marker attribute for customizing individual API methods

This attribute is parsed by #[plugin_api_impl] but doesn’t generate any code itself.

§Options

  • skip - Exclude method from TypeScript generation
  • js_name = "..." - Custom JavaScript method name
  • async_promise - Method returns Promise<T>
  • async_thenable - Method returns ProcessHandle<T> (cancellable)
  • ts_type = "..." - Custom TypeScript type for a parameter
  • ts_return = "..." - Custom TypeScript return type

§Examples

// Skip internal helper
#[plugin_api(skip)]
fn internal_helper(&self) { ... }

// Async method with custom return type
#[plugin_api(async_promise, js_name = "fetchData", ts_return = "DataResult")]
fn fetch_data_start(&self) -> u64 { ... }

// Cancellable operation
#[plugin_api(async_thenable, js_name = "spawnProcess", ts_return = "SpawnResult")]
fn spawn_process_start(&self, cmd: String) -> u64 { ... }