MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / call

Method call

crates/opencode-plugin/src/subprocess/client.rs:423–443  ·  view source on GitHub ↗

Send a JSON-RPC request and wait for the response.

(
        &self,
        method: &str,
        params: Option<Value>,
    )

Source from the content-addressed store, hash-verified

421
422 /// Send a JSON-RPC request and wait for the response.
423 async fn call<T: serde::de::DeserializeOwned>(
424 &self,
425 method: &str,
426 params: Option<Value>,
427 ) -> Result<T, PluginSubprocessError> {
428 let _rpc_guard = self.rpc_lock.lock().await;
429 let id = self.next_id();
430 self.write_request(id, method, params).await?;
431
432 // Read response with timeout
433 let response = tokio::time::timeout(self.timeout, self.read_response_for_id(id))
434 .await
435 .map_err(|_| PluginSubprocessError::Timeout)??;
436
437 if let Some(err) = response.error {
438 return Err(err.into());
439 }
440
441 let result = response.result.unwrap_or(Value::Null);
442 serde_json::from_value(result).map_err(Into::into)
443 }
444
445 async fn write_request(
446 &self,

Callers 7

spawnMethod · 0.80
invoke_hookMethod · 0.80
auth_authorizeMethod · 0.80
auth_callbackMethod · 0.80
auth_loadMethod · 0.80
auth_fetchMethod · 0.80
shutdownMethod · 0.80

Calls 3

write_requestMethod · 0.80
read_response_for_idMethod · 0.80
next_idMethod · 0.45

Tested by

no test coverage detected