pub struct HostBridge { /* private fields */ }Expand description
A JSON-RPC 2.0 bridge to a host process over stdin/stdout.
The bridge sends requests to the host on stdout and receives responses on stdin. A background task reads stdin and dispatches responses to waiting callers by request ID. All stdout writes are serialized through a mutex to prevent interleaving.
Implementations§
Source§impl HostBridge
impl HostBridge
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new bridge and spawn the stdin reader task.
Must be called within a tokio LocalSet (uses spawn_local for the stdin reader since it’s single-threaded).
Sourcepub async fn call(&self, method: &str, params: Value) -> Result<Value, VmError>
pub async fn call(&self, method: &str, params: Value) -> Result<Value, VmError>
Send a JSON-RPC request to the host and wait for the response. Times out after 5 minutes to prevent deadlocks.
Sourcepub fn notify(&self, method: &str, params: Value)
pub fn notify(&self, method: &str, params: Value)
Send a JSON-RPC notification to the host (no response expected). Serialized through the stdout mutex to prevent interleaving.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Check if the host has sent a cancel notification.
Sourcepub fn send_output(&self, text: &str)
pub fn send_output(&self, text: &str)
Send an output notification (for log/print in bridge mode).
Sourcepub fn send_progress(&self, phase: &str, message: &str)
pub fn send_progress(&self, phase: &str, message: &str)
Send a progress notification.