pub struct WasmExecutor { /* private fields */ }Expand description
Executes .wasm32-wasi capability binaries via Wasmtime.
Every invocation creates a fresh Wasmtime Store — no state leaks between calls.
Implementations§
Source§impl WasmExecutor
impl WasmExecutor
Sourcepub fn new() -> Result<Self, ExecutorError>
pub fn new() -> Result<Self, ExecutorError>
Create a new WasmExecutor with a default Wasmtime engine.
§Errors
Returns ExecutorError::RuntimeSetupFailed if Wasmtime cannot initialise.
Sourcepub fn with_limits(limits: WasmExecutionLimits) -> Result<Self, ExecutorError>
pub fn with_limits(limits: WasmExecutionLimits) -> Result<Self, ExecutorError>
Create a WasmExecutor with explicit per-invocation resource limits.
§Errors
Returns ExecutorError::RuntimeSetupFailed if Wasmtime cannot initialise.
Sourcepub fn with_limits_and_cache_config(
limits: WasmExecutionLimits,
cache_config: WasmModuleCacheConfig,
) -> Result<Self, ExecutorError>
pub fn with_limits_and_cache_config( limits: WasmExecutionLimits, cache_config: WasmModuleCacheConfig, ) -> Result<Self, ExecutorError>
Create a WasmExecutor with explicit resource limits and module cache bounds.
§Errors
Returns ExecutorError::RuntimeSetupFailed if Wasmtime cannot initialise.
Sourcepub fn module_cache_stats(&self) -> WasmModuleCacheStats
pub fn module_cache_stats(&self) -> WasmModuleCacheStats
Return current compiled-module cache counters.
Sourcepub fn binary_cache_stats(&self) -> WasmBinaryCacheStats
pub fn binary_cache_stats(&self) -> WasmBinaryCacheStats
Return current on-disk binary cache counters.
Source§impl WasmExecutor
impl WasmExecutor
Sourcepub fn run_bytes(
&self,
wasm_bytes: &[u8],
input: &Value,
) -> Result<Value, ExecutorError>
pub fn run_bytes( &self, wasm_bytes: &[u8], input: &Value, ) -> Result<Value, ExecutorError>
Execute pre-loaded WASM bytes with the given input.
Exposed separately so tests can pass raw bytes without needing a file on disk.
The capability is treated as Stateless with no declared emits — it
cannot call traverse_host::emit_event. Use
run_bytes_with_capability to
exercise the event-emit host function.
§Errors
Returns ExecutorError if input serialization fails, the WASM module cannot be
compiled or linked, execution fails, or stdout is not valid JSON.
Sourcepub fn run_bytes_with_host_abi(
&self,
wasm_bytes: &[u8],
input: &Value,
abi_version: &str,
) -> Result<Value, ExecutorError>
pub fn run_bytes_with_host_abi( &self, wasm_bytes: &[u8], input: &Value, abi_version: &str, ) -> Result<Value, ExecutorError>
Execute pre-loaded WASM bytes with an explicit Traverse Host ABI version.
§Errors
Returns ExecutorError if ABI validation fails or execution cannot complete.
Sourcepub fn run_bytes_with_capability(
&self,
wasm_bytes: &[u8],
input: &Value,
capability_id: &str,
emits: &[EventReference],
service_type: ServiceType,
) -> Result<ExecutorOutput, ExecutorError>
pub fn run_bytes_with_capability( &self, wasm_bytes: &[u8], input: &Value, capability_id: &str, emits: &[EventReference], service_type: ServiceType, ) -> Result<ExecutorOutput, ExecutorError>
Execute pre-loaded WASM bytes as a specific capability, exercising
traverse_host::emit_event validation against emits/service_type
exactly as CapabilityExecutor::execute does.
§Errors
Returns ExecutorError if ABI validation fails or execution cannot complete.
Sourcepub fn run_bytes_with_mediated_connectors(
&self,
wasm_bytes: &[u8],
input: &Value,
capability_id: &str,
connector_context: MediatedConnectorContext,
) -> Result<ExecutorOutput, ExecutorError>
pub fn run_bytes_with_mediated_connectors( &self, wasm_bytes: &[u8], input: &Value, capability_id: &str, connector_context: MediatedConnectorContext, ) -> Result<ExecutorOutput, ExecutorError>
Execute bytes with host-owned, activated connector bindings. This is the
only API that can enable connector_invoke; callers that do not supply
this context retain the deny-by-default handler.
§Errors
Returns ExecutorError when the module, guest memory, or execution
cannot be completed safely.
Trait Implementations§
Source§impl CapabilityExecutor for WasmExecutor
impl CapabilityExecutor for WasmExecutor
Source§fn execute(
&self,
capability: &ExecutorCapability,
input: &Value,
) -> Result<ExecutorOutput, ExecutorError>
fn execute( &self, capability: &ExecutorCapability, input: &Value, ) -> Result<ExecutorOutput, ExecutorError>
Auto Trait Implementations§
impl !Freeze for WasmExecutor
impl !RefUnwindSafe for WasmExecutor
impl !UnwindSafe for WasmExecutor
impl Send for WasmExecutor
impl Sync for WasmExecutor
impl Unpin for WasmExecutor
impl UnsafeUnpin for WasmExecutor
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
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: Sized + AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: Sized + AsFilelike,
self file descriptor. Read moreSource§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> ⓘ
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> ⓘ
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