MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / send_rpc_request

Method send_rpc_request

sdk/rust/src/tappd_client.rs:74–109  ·  view source on GitHub ↗
(
        &self,
        path: &str,
        payload: &S,
    )

Source from the content-addressed store, hash-verified

72 }
73
74 async fn send_rpc_request<S: Serialize, D: DeserializeOwned>(
75 &self,
76 path: &str,
77 payload: &S,
78 ) -> anyhow::Result<D> {
79 match &self.client {
80 TappdClientKind::Http => {
81 let client = Client::new();
82 let url = format!(
83 "{}/{}",
84 self.base_url.trim_end_matches('/'),
85 path.trim_start_matches('/')
86 );
87 let res = client
88 .post(&url)
89 .json(payload)
90 .header("Content-Type", "application/json")
91 .send()
92 .await?
93 .error_for_status()?;
94 Ok(res.json().await?)
95 }
96 TappdClientKind::Unix => {
97 let mut unix_client = ClientUnix::try_new(&self.endpoint).await?;
98 let res = unix_client
99 .send_request_json::<_, _, Value>(
100 path,
101 Method::POST,
102 &[("Content-Type", "application/json")],
103 Some(&payload),
104 )
105 .await?;
106 Ok(res.1)
107 }
108 }
109 }
110
111 /// Derives a key from the Tappd service using the path as both path and subject
112 pub async fn derive_key(&self, path: &str) -> Result<DeriveKeyResponse> {

Callers 3

get_quoteMethod · 0.45
infoMethod · 0.45

Calls 1

sendMethod · 0.80

Tested by

no test coverage detected