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§
Sourcefn file_extensions(&self) -> &'static [&'static str]
fn file_extensions(&self) -> &'static [&'static str]
Get the file extensions this runtime handles (e.g., [“.lua”]).
Sourcefn init(&mut self, config: &PluginConfig) -> PluginResult<()>
fn init(&mut self, config: &PluginConfig) -> PluginResult<()>
Initialize the runtime with configuration.
Sourcefn load_plugin(&mut self, id: &str, source: &Path) -> PluginResult<PluginHandle>
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.
Sourcefn unload_plugin(&mut self, handle: PluginHandle) -> PluginResult<()>
fn unload_plugin(&mut self, handle: PluginHandle) -> PluginResult<()>
Unload a previously loaded plugin.
Sourcefn get_metadata(&self, handle: PluginHandle) -> Option<&PluginMetadata>
fn get_metadata(&self, handle: PluginHandle) -> Option<&PluginMetadata>
Get metadata about a loaded plugin.
Sourcefn has_hook(&self, handle: PluginHandle, hook_name: &str) -> bool
fn has_hook(&self, handle: PluginHandle, hook_name: &str) -> bool
Check if a plugin implements a specific hook.
Sourcefn call_hook_sync(
&self,
handle: PluginHandle,
hook: &Hook,
ctx: &HookContext,
) -> PluginResult<HookResult>
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).
Sourcefn 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_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).
Sourcefn call_method<'a>(
&'a self,
handle: PluginHandle,
method: &'a str,
args: Vec<Value>,
) -> Pin<Box<dyn Future<Output = PluginResult<Value>> + 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>>
Call an arbitrary method on a plugin.
Sourcefn create_isolated_context(
&self,
sandbox: &SandboxConfig,
) -> PluginResult<Box<dyn IsolatedContext>>
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.
Sourcefn loaded_plugins(&self) -> Vec<PluginHandle>
fn loaded_plugins(&self) -> Vec<PluginHandle>
Get the list of loaded plugin handles.
Sourcefn shutdown(&mut self) -> PluginResult<()>
fn shutdown(&mut self) -> PluginResult<()>
Shutdown the runtime and cleanup resources.