Adds `crates/wasm-actor/` (swactor-wasm-actor), which embeds wasmtime-sandboxed Wasm instances inside regular swactor actors. Messages flow as raw bytes through the guest ↔ host contract (alloc/handle exports, swactor.send import). The host drains an outbox after each handle call and routes messages via ctx.send(). Includes 3 no_std guest modules (echo, double, silent) and 7 integration tests covering roundtrip delivery, binary fidelity, multi-send, error cases, engine sharing, and native↔wasm interop. Authored by Claude, lovingly guided by Zachery Aaron Shores-Chmielewski
27 lines
774 B
Rust
27 lines
774 B
Rust
use std::fmt;
|
|
|
|
/// Errors that can occur when building or running a WasmActor.
|
|
#[derive(Debug)]
|
|
pub enum WasmActorError {
|
|
/// A required export is missing from the Wasm module.
|
|
MissingExport(&'static str),
|
|
/// The Wasm module failed to compile or instantiate.
|
|
Wasmtime(wasmtime::Error),
|
|
}
|
|
|
|
impl fmt::Display for WasmActorError {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
match self {
|
|
Self::MissingExport(name) => write!(f, "missing required export: `{name}`"),
|
|
Self::Wasmtime(e) => write!(f, "wasmtime error: {e}"),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl std::error::Error for WasmActorError {}
|
|
|
|
impl From<wasmtime::Error> for WasmActorError {
|
|
fn from(e: wasmtime::Error) -> Self {
|
|
Self::Wasmtime(e)
|
|
}
|
|
}
|