on master help sign in
dap: implement threads request
7d2d4edDmitry Sharshakov
helix-dap/examples/dap-basic.rs+1
@@ -42,6 +42,7 @@ pub async fn main() -> Result<()> {
42
42
43 println!("configurationDone: {:?}", client.configuration_done().await);
43 println!("configurationDone: {:?}", client.configuration_done().await);
44 println!("stopped: {:?}", client.wait_for_stopped().await);
44 println!("stopped: {:?}", client.wait_for_stopped().await);
45+ println!("threads: {:#?}", client.threads().await);
45 println!("stack trace: {:#?}", client.stack_trace(1).await);
46 println!("stack trace: {:#?}", client.stack_trace(1).await);
46
47
47 let mut _in = String::new();
48 let mut _in = String::new();
helix-dap/src/client.rs+21
@@ -148,6 +148,19 @@ struct StackTraceResponseBody {
148 stack_frames: Vec<StackFrame>,
148 stack_frames: Vec<StackFrame>,
149}
149}
150
150
151+#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
152+#[serde(rename_all = "camelCase")]
153+pub struct Thread {
154+ id: usize,
155+ name: String,
156+}
157+
158+#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
159+#[serde(rename_all = "camelCase")]
160+struct ThreadsResponseBody {
161+ threads: Vec<Thread>,
162+}
163+
151#[derive(Debug)]
164#[derive(Debug)]
152pub struct Client {
165pub struct Client {
153 id: usize,
166 id: usize,
@@ -349,4 +362,12 @@ impl Client {
349
362
350 Ok((body.stack_frames, body.total_frames))
363 Ok((body.stack_frames, body.total_frames))
351 }
364 }
365+
366+ pub async fn threads(&mut self) -> Result<Vec<Thread>> {
367+ let response = self.request("threads".to_owned(), None).await?;
368+
369+ let body: ThreadsResponseBody = from_value(response.body.unwrap()).unwrap();
370+
371+ Ok(body.threads)
372+ }
352}
373}