diff options
author | Dmitry Sharshakov | 2021-08-14 06:14:05 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-08-20 04:43:54 +0000 |
commit | 09390be6a568bcf7052c57bf10219c448413d5b0 (patch) | |
tree | dba12ddc1f7010e62e3729f8c50e5f000bea38d7 /helix-dap/examples/dap-basic.rs | |
parent | c72475bc3084f206c3d0c612dd86afe324c6931e (diff) |
dap-basic: handle output events
Diffstat (limited to 'helix-dap/examples/dap-basic.rs')
-rw-r--r-- | helix-dap/examples/dap-basic.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/helix-dap/examples/dap-basic.rs b/helix-dap/examples/dap-basic.rs index 76fc0dd3..fb52f855 100644 --- a/helix-dap/examples/dap-basic.rs +++ b/helix-dap/examples/dap-basic.rs @@ -1,5 +1,7 @@ -use helix_dap::{Client, Result, SourceBreakpoint}; +use helix_dap::{Client, Event, OutputEventBody, Result, SourceBreakpoint}; use serde::{Deserialize, Serialize}; +use serde_json::from_value; +use tokio::sync::mpsc::Receiver; #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] @@ -8,6 +10,12 @@ struct LaunchArguments { program: String, } +async fn output(mut output_event: Receiver<Event>) { + let body: OutputEventBody = + from_value(output_event.recv().await.unwrap().body.unwrap()).unwrap(); + println!("{:?}", body); +} + #[tokio::main] pub async fn main() -> Result<()> { let base_config = fern::Dispatch::new().level(log::LevelFilter::Info); @@ -25,6 +33,9 @@ pub async fn main() -> Result<()> { println!("create: {:?}", client); let mut client = client?; + let output_event = client.listen_for_event("output".to_owned()).await; + tokio::spawn(output(output_event)); + println!("init: {:?}", client.initialize("go".to_owned()).await); println!("caps: {:#?}", client.capabilities()); |