@@ -1,4 +1,5 @@
1use crate::{
1use crate::{
2+ requests::DisconnectArguments,
2 transport::{Payload, Request, Response, Transport},
3 transport::{Payload, Request, Response, Transport},
4 Error, Result, ThreadId,
5 Error, Result, ThreadId,
@@ -31,6 +32,7 @@ pub struct Client {
31 _process: Option<Child>,
32 _process: Option<Child>,
32 server_tx: UnboundedSender<Payload>,
33 server_tx: UnboundedSender<Payload>,
33 request_counter: AtomicU64,
34 request_counter: AtomicU64,
35+ connection_type: Option<ConnectionType>,
34 pub caps: Option<DebuggerCapabilities>,
36 pub caps: Option<DebuggerCapabilities>,
35 // thread_id -> frames
37 // thread_id -> frames
36 pub stack_frames: HashMap<ThreadId, Vec<StackFrame>>,
38 pub stack_frames: HashMap<ThreadId, Vec<StackFrame>>,
@@ -41,6 +43,12 @@ pub struct Client {
41 pub quirks: DebuggerQuirks,
43 pub quirks: DebuggerQuirks,
46+#[derive(Clone, Copy, Debug)]
47+pub enum ConnectionType {
44impl Client {
52impl Client {
45 // Spawn a process and communicate with it by either TCP or stdio
53 // Spawn a process and communicate with it by either TCP or stdio
46 pub async fn process(
54 pub async fn process(
@@ -78,7 +86,7 @@ impl Client {
78 server_tx,
86 server_tx,
79 request_counter: AtomicU64::new(0),
87 request_counter: AtomicU64::new(0),
80 caps: None,
88 caps: None,
81− //
89+ connection_type: None,
82 stack_frames: HashMap::new(),
90 stack_frames: HashMap::new(),
83 thread_states: HashMap::new(),
91 thread_states: HashMap::new(),
84 thread_id: None,
92 thread_id: None,
@@ -207,6 +215,10 @@ impl Client {
218+ pub fn connection_type(&self) -> Option<ConnectionType> {
219+ self.connection_type
210 fn next_request_id(&self) -> u64 {
222 fn next_request_id(&self) -> u64 {
211 self.request_counter.fetch_add(1, Ordering::Relaxed)
223 self.request_counter.fetch_add(1, Ordering::Relaxed)
@@ -334,15 +346,21 @@ impl Client {
351+ args: Option<DisconnectArguments>,
337− pub fn disconnect(&self) -> impl Future<Output = Result<Value>> {
352+ ) -> impl Future<Output = Result<Value>> {
353+ self.connection_type = None;
338− self.call::<requests::Disconnect>(())
354+ self.call::<requests::Disconnect>(args)
341− pub fn launch(&self, args: serde_json::Value) -> impl Future<Output = Result<Value>> {
357+ pub fn launch(&mut self, args: serde_json::Value) -> impl Future<Output = Result<Value>> {
358+ self.connection_type = Some(ConnectionType::Launch);
342 self.call::<requests::Launch>(args)
359 self.call::<requests::Launch>(args)
345− pub fn attach(&self, args: serde_json::Value) -> impl Future<Output = Result<Value>> {
362+ pub fn attach(&mut self, args: serde_json::Value) -> impl Future<Output = Result<Value>> {
363+ self.connection_type = Some(ConnectionType::Attach);
346 self.call::<requests::Attach>(args)
364 self.call::<requests::Attach>(args)