muse_code_sdk/connection/
handshake.rs1use crate::connection::{Connection, ConnectionError, ProtocolError};
2use crate::handshake::{HandshakeConnection, HandshakeFuture};
3
4impl HandshakeConnection for Connection {
5 type Error = ConnectionError;
6
7 fn request<'a>(
8 &'a mut self,
9 method: &'static str,
10 params: serde_json::Value,
11 ) -> HandshakeFuture<'a, serde_json::Value, Self::Error> {
12 Box::pin(async move {
13 let params = params.as_object().cloned().ok_or_else(|| {
14 ConnectionError::Protocol(ProtocolError::new(
15 "handshake request params must be an object",
16 None,
17 ))
18 })?;
19 Connection::request(self, method, Some(params))
20 .await
21 .map(serde_json::Value::Object)
22 })
23 }
24
25 fn notify<'a>(&'a mut self, method: &'static str) -> HandshakeFuture<'a, (), Self::Error> {
26 Box::pin(Connection::notify(self, method, None))
27 }
28}