pub trait HostCallBridge {
// Required method
fn dispatch(
&self,
capability: &str,
operation: &str,
params: &BTreeMap<String, VmValue>,
) -> Result<Option<VmValue>, VmError>;
}Expand description
Embedder-supplied bridge for host_call ops.
Embedders (debug adapters, CLIs, IDE hosts) implement this trait to
satisfy capability/operation pairs that harn-vm itself doesn’t know how
to handle. Returning Ok(None) means “I don’t handle this op — fall
through to the built-in fallbacks (env-derived defaults, then the
unsupported operation error)”. Ok(Some(value)) is the result;
Err(VmError::Thrown(_)) surfaces as a Harn exception.
The trait is intentionally synchronous. Bridges that need async I/O
(e.g. DAP reverse requests) should drive their own runtime or use a
blocking channel — see harn-dap’s DapHostBridge for the canonical
pattern. Sync keeps the boundary simple and avoids forcing the entire
dispatch path into an opaque future.