Skip to main content

PluginRuntime

Trait PluginRuntime 

Source
pub trait PluginRuntime: Send + Sync {
Show 13 methods // Required methods fn name(&self) -> &'static str; fn file_extensions(&self) -> &'static [&'static str]; fn init(&mut self, config: &PluginConfig) -> PluginResult<()>; fn load_plugin( &mut self, id: &str, source: &Path, ) -> PluginResult<PluginHandle>; fn unload_plugin(&mut self, handle: PluginHandle) -> PluginResult<()>; fn get_metadata(&self, handle: PluginHandle) -> Option<&PluginMetadata>; fn has_hook(&self, handle: PluginHandle, hook_name: &str) -> bool; fn call_hook_sync( &self, handle: PluginHandle, hook: &Hook, ctx: &HookContext, ) -> PluginResult<HookResult>; fn call_hook_async<'a>( &'a self, handle: PluginHandle, hook: &'a Hook, ctx: &'a HookContext, ) -> Pin<Box<dyn Future<Output = PluginResult<HookResult>> + Send + 'a>>; fn call_method<'a>( &'a self, handle: PluginHandle, method: &'a str, args: Vec<Value>, ) -> Pin<Box<dyn Future<Output = PluginResult<Value>> + Send + 'a>>; fn create_isolated_context( &self, sandbox: &SandboxConfig, ) -> PluginResult<Box<dyn IsolatedContext>>; fn loaded_plugins(&self) -> Vec<PluginHandle>; fn shutdown(&mut self) -> PluginResult<()>;
}
Expand description

Trait that all plugin runtime implementations must satisfy.

This trait abstracts over the specific scripting language (Lua, Rhai, WASM) allowing plugins to be written in any supported language.

Required Methods§

Source

fn name(&self) -> &'static str

Get the name of this runtime (e.g., “lua”, “rhai”, “wasm”).

Source

fn file_extensions(&self) -> &'static [&'static str]

Get the file extensions this runtime handles (e.g., [“.lua”]).

Source

fn init(&mut self, config: &PluginConfig) -> PluginResult<()>

Initialize the runtime with configuration.

Source

fn load_plugin(&mut self, id: &str, source: &Path) -> PluginResult<PluginHandle>

Load a plugin from a file path.

Returns a handle that can be used to interact with the plugin.

Source

fn unload_plugin(&mut self, handle: PluginHandle) -> PluginResult<()>

Unload a previously loaded plugin.

Source

fn get_metadata(&self, handle: PluginHandle) -> Option<&PluginMetadata>

Get metadata about a loaded plugin.

Source

fn has_hook(&self, handle: PluginHandle, hook_name: &str) -> bool

Check if a plugin implements a specific hook.

Source

fn call_hook_sync( &self, handle: PluginHandle, hook: &Hook, ctx: &HookContext, ) -> PluginResult<HookResult>

Call a hook on a plugin synchronously.

Used for hooks that must complete immediately (e.g., render hooks).

Source

fn call_hook_async<'a>( &'a self, handle: PluginHandle, hook: &'a Hook, ctx: &'a HookContext, ) -> Pin<Box<dyn Future<Output = PluginResult<HookResult>> + Send + 'a>>

Call a hook on a plugin asynchronously.

Used for hooks that may take time (e.g., scan complete hooks).

Source

fn call_method<'a>( &'a self, handle: PluginHandle, method: &'a str, args: Vec<Value>, ) -> Pin<Box<dyn Future<Output = PluginResult<Value>> + Send + 'a>>

Call an arbitrary method on a plugin.

Source

fn create_isolated_context( &self, sandbox: &SandboxConfig, ) -> PluginResult<Box<dyn IsolatedContext>>

Create an isolated context for running async plugin code.

Isolated contexts have limited API access and their own Lua/Rhai state, making them safe to run in background tasks.

Source

fn loaded_plugins(&self) -> Vec<PluginHandle>

Get the list of loaded plugin handles.

Source

fn shutdown(&mut self) -> PluginResult<()>

Shutdown the runtime and cleanup resources.

Implementors§