pub struct WasmPluginRuntime { /* private fields */ }Expand description
WASM plugin runtime
Implementations§
Source§impl WasmPluginRuntime
impl WasmPluginRuntime
Sourcepub fn new(config: &PluginRuntimeConfig) -> Result<Self, PluginError>
pub fn new(config: &PluginRuntimeConfig) -> Result<Self, PluginError>
Create a new WASM runtime
Sourcepub fn kv(&self) -> &KvBackend
pub fn kv(&self) -> &KvBackend
Expose the per-plugin KV backend so admin/test code can seed or inspect a plugin’s state without going through WASM.
Sourcepub fn config(&self) -> &PluginRuntimeConfig
pub fn config(&self) -> &PluginRuntimeConfig
Expose the runtime config so the plugin manager can consult
fields it owns (e.g. trust_root) without holding a separate
copy.
Sourcepub fn instantiate(
&self,
manifest: &PluginManifest,
wasm_bytes: &[u8],
) -> Result<LoadedPlugin, PluginError>
pub fn instantiate( &self, manifest: &PluginManifest, wasm_bytes: &[u8], ) -> Result<LoadedPlugin, PluginError>
Instantiate a plugin from manifest and WASM bytes
Sourcepub fn call_hook(
&self,
plugin: &LoadedPlugin,
hook: HookType,
args: &[u8],
) -> Result<Vec<u8>, PluginError>
pub fn call_hook( &self, plugin: &LoadedPlugin, hook: HookType, args: &[u8], ) -> Result<Vec<u8>, PluginError>
Call a hook on a plugin via wasmtime.
- Build a fresh
Store(wasmtime stores are not Sync, so each invocation is isolated). - Apply fuel metering (per-call fuel cap) when configured.
- Instantiate the module against an empty Linker — host functions are TODO; plugins that import them will fail at instantiation with a clear error message.
- Look up
memory,alloc,dealloc, and the named hook function exports. - Allocate a slot in plugin memory, write
args, call the hook, decode(result_ptr, result_len), copy the result bytes out. - Free both input and output slots via
dealloc. - Drop the store; the plugin’s per-call state is gone.
Sourcepub fn call_pre_query(
&self,
plugin: &LoadedPlugin,
ctx: &QueryContext,
) -> Result<PreQueryResult, PluginError>
pub fn call_pre_query( &self, plugin: &LoadedPlugin, ctx: &QueryContext, ) -> Result<PreQueryResult, PluginError>
Call pre-query hook
Sourcepub fn call_authenticate(
&self,
plugin: &LoadedPlugin,
request: &AuthRequest,
) -> Result<AuthResult, PluginError>
pub fn call_authenticate( &self, plugin: &LoadedPlugin, request: &AuthRequest, ) -> Result<AuthResult, PluginError>
Call authenticate hook
Sourcepub fn call_route(
&self,
plugin: &LoadedPlugin,
ctx: &QueryContext,
) -> Result<RouteResult, PluginError>
pub fn call_route( &self, plugin: &LoadedPlugin, ctx: &QueryContext, ) -> Result<RouteResult, PluginError>
Call route hook
Sourcepub fn stats(&self) -> RuntimeStats
pub fn stats(&self) -> RuntimeStats
Get runtime statistics
Auto Trait Implementations§
impl !Freeze for WasmPluginRuntime
impl !RefUnwindSafe for WasmPluginRuntime
impl Send for WasmPluginRuntime
impl Sync for WasmPluginRuntime
impl Unpin for WasmPluginRuntime
impl UnsafeUnpin for WasmPluginRuntime
impl !UnwindSafe for WasmPluginRuntime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more