on master help sign in
dap-basic: parse stop event
b3be6b2Dmitry Sharshakov
helix-dap/examples/dap-basic.rs+4−2
@@ -1,4 +1,4 @@
1−use helix_dap::{Client, Event, OutputEventBody, Result, SourceBreakpoint};
1+use helix_dap::{Client, Event, OutputEventBody, Result, SourceBreakpoint, StoppedEventBody};
2use serde::{Deserialize, Serialize};
2use serde::{Deserialize, Serialize};
3use serde_json::from_value;
3use serde_json::from_value;
4use tokio::sync::mpsc::Receiver;
4use tokio::sync::mpsc::Receiver;
@@ -75,7 +75,9 @@ pub async fn main() -> Result<()> {
75
75
76 println!("configurationDone: {:?}", client.configuration_done().await);
76 println!("configurationDone: {:?}", client.configuration_done().await);
77
77
78+ let stop: StoppedEventBody =
79+ from_value(stopped_event.recv().await.unwrap().body.unwrap()).unwrap();
78− println!("stopped: {:?}", stopped_event.recv().await);
80+ println!("stopped: {:?}", stop);
79
81
80 println!("threads: {:#?}", client.threads().await);
82 println!("threads: {:#?}", client.threads().await);
81 let bt = client.stack_trace(1).await.expect("expected stack trace");
83 let bt = client.stack_trace(1).await.expect("expected stack trace");
helix-dap/src/client.rs+12
@@ -267,6 +267,18 @@ pub struct OutputEventBody {
267 pub data: Option<Value>,
267 pub data: Option<Value>,
268}
268}
269
269
270+#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
271+#[serde(rename_all = "camelCase")]
272+pub struct StoppedEventBody {
273+ pub reason: String,
274+ pub description: Option<String>,
275+ pub thread_id: Option<usize>,
276+ pub preserve_focus_hint: Option<bool>,
277+ pub text: Option<String>,
278+ pub all_threads_stopped: Option<bool>,
279+ pub hit_breakpoint_ids: Option<Vec<usize>>,
280+}
281+
270#[derive(Debug)]
282#[derive(Debug)]
271pub struct Client {
283pub struct Client {
272 id: usize,
284 id: usize,
helix-dap/src/lib.rs+1−1
@@ -1,7 +1,7 @@
1mod client;
1mod client;
2mod transport;
2mod transport;
3
3
4−pub use client::{Breakpoint, Client, OutputEventBody, SourceBreakpoint};
4+pub use client::{Breakpoint, Client, OutputEventBody, SourceBreakpoint, StoppedEventBody};
5pub use transport::{Event, Payload, Request, Response, Transport};
5pub use transport::{Event, Payload, Request, Response, Transport};
6
6
7use thiserror::Error;
7use thiserror::Error;