Skip to content

Commit 9b3218e

Browse files
authored
Merge pull request #4 from tuddman/rust-sdk-addendum-2
fix(client): suggested changes
2 parents 1ed691a + 4a73b54 commit 9b3218e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

sdk/rust/src/dstack_client.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,16 +193,15 @@ impl DstackClient {
193193
}
194194
ClientKind::Unix => {
195195
let mut unix_client = ClientUnix::try_new(&self.endpoint).await?;
196-
let json_payload = serde_json::to_value(payload)?;
197196
let res = unix_client
198-
.send_request_json::<Value, Value, Value>(
197+
.send_request_json::<_, _, Value>(
199198
path,
200199
Method::POST,
201200
&[("Content-Type", "application/json")],
202-
Some(&json_payload),
201+
Some(&payload),
203202
)
204203
.await?;
205-
Ok(serde_json::from_value(res.1)?)
204+
Ok(res.1)
206205
}
207206
}
208207
}
@@ -224,7 +223,7 @@ impl DstackClient {
224223

225224
pub async fn get_quote(&self, report_data: Vec<u8>) -> Result<GetQuoteResponse> {
226225
if report_data.is_empty() || report_data.len() > 64 {
227-
return Err(anyhow!("Invalid report data length"));
226+
anyhow::bail!("Invalid report data length")
228227
}
229228
let hex_data = hex_encode(report_data);
230229
let data = json!({ "report_data": hex_data });
@@ -241,7 +240,7 @@ impl DstackClient {
241240

242241
pub async fn emit_event(&self, event: String, payload: Vec<u8>) -> Result<()> {
243242
if event.is_empty() {
244-
return Err(anyhow!("Event name cannot be empty"));
243+
anyhow::bail!("Event name cannot be empty")
245244
}
246245
let hex_payload = hex_encode(payload);
247246
let data = json!({ "event": event, "payload": hex_payload });

0 commit comments

Comments
 (0)