pub struct DapClient {
pub capabilities: Capabilities,
/* private fields */
}Expand description
DAP client for communicating with a debug adapter
Fields§
§capabilities: CapabilitiesAdapter capabilities (populated after initialize)
Implementations§
Source§impl DapClient
impl DapClient
Sourcepub async fn spawn(adapter_path: &Path, args: &[String]) -> Result<Self>
pub async fn spawn(adapter_path: &Path, args: &[String]) -> Result<Self>
Spawn a new DAP adapter and create a client
Sourcepub async fn spawn_tcp(
adapter_path: &Path,
args: &[String],
spawn_style: &TcpSpawnStyle,
) -> Result<Self>
pub async fn spawn_tcp( adapter_path: &Path, args: &[String], spawn_style: &TcpSpawnStyle, ) -> Result<Self>
Spawn a new DAP adapter that uses TCP for communication (e.g., Delve, js-debug)
Sourcepub fn take_event_receiver(&mut self) -> Option<UnboundedReceiver<Event>>
pub fn take_event_receiver(&mut self) -> Option<UnboundedReceiver<Event>>
Take the event receiver (can only be called once)
Sourcepub async fn request<T: DeserializeOwned>(
&mut self,
command: &str,
arguments: Option<Value>,
) -> Result<T>
pub async fn request<T: DeserializeOwned>( &mut self, command: &str, arguments: Option<Value>, ) -> Result<T>
Send a request and wait for the response with timeout
Sourcepub async fn request_with_timeout<T: DeserializeOwned>(
&mut self,
command: &str,
arguments: Option<Value>,
timeout: Duration,
) -> Result<T>
pub async fn request_with_timeout<T: DeserializeOwned>( &mut self, command: &str, arguments: Option<Value>, timeout: Duration, ) -> Result<T>
Send a request and wait for the response with configurable timeout
Note: We register the pending response handler BEFORE sending the request to avoid a race condition where a fast adapter response arrives before we’ve set up the handler.
Sourcepub async fn poll_event(&mut self) -> Result<Option<Event>>
pub async fn poll_event(&mut self) -> Result<Option<Event>>
Poll for events - this is now non-blocking since events are already in the channel Note: This method is kept for API compatibility but is no longer necessary since the background reader task handles all event ingestion
Sourcepub async fn initialize(&mut self, adapter_id: &str) -> Result<Capabilities>
pub async fn initialize(&mut self, adapter_id: &str) -> Result<Capabilities>
Initialize the debug adapter
Sourcepub async fn initialize_with_timeout(
&mut self,
adapter_id: &str,
timeout: Duration,
) -> Result<Capabilities>
pub async fn initialize_with_timeout( &mut self, adapter_id: &str, timeout: Duration, ) -> Result<Capabilities>
Initialize the debug adapter with configurable timeout
Sourcepub async fn wait_initialized(&mut self) -> Result<()>
pub async fn wait_initialized(&mut self) -> Result<()>
Wait for the initialized event with timeout
This method waits for the initialized event which comes through the event channel. It’s called before the session takes the event receiver.
Sourcepub async fn wait_initialized_with_timeout(
&mut self,
timeout: Duration,
) -> Result<()>
pub async fn wait_initialized_with_timeout( &mut self, timeout: Duration, ) -> Result<()>
Wait for the initialized event with configurable timeout
§Event Ordering Note
This method consumes events from the channel until it sees Initialized.
Non-Initialized events are re-sent to the channel so they won’t be lost.
This is safe because:
- The session hasn’t taken the receiver yet (wait_initialized is called during setup)
- The re-sent events go back to the same unbounded channel
- The background reader task continues adding new events after our re-sent ones
Events will be received in order: [re-sent events] + [new events from reader]
Sourcepub async fn launch(&mut self, args: LaunchArguments) -> Result<()>
pub async fn launch(&mut self, args: LaunchArguments) -> Result<()>
Launch a program for debugging
Sourcepub async fn launch_no_wait(&mut self, args: LaunchArguments) -> Result<i64>
pub async fn launch_no_wait(&mut self, args: LaunchArguments) -> Result<i64>
Launch a program for debugging without waiting for response
Some debuggers (like debugpy) don’t respond to launch until after configurationDone is sent. This sends the launch request but doesn’t wait for the response.
Sourcepub async fn attach(&mut self, args: AttachArguments) -> Result<()>
pub async fn attach(&mut self, args: AttachArguments) -> Result<()>
Attach to a running process
Sourcepub async fn configuration_done(&mut self) -> Result<()>
pub async fn configuration_done(&mut self) -> Result<()>
Signal that configuration is done
Sourcepub async fn set_breakpoints(
&mut self,
source_path: &Path,
breakpoints: Vec<SourceBreakpoint>,
) -> Result<Vec<Breakpoint>>
pub async fn set_breakpoints( &mut self, source_path: &Path, breakpoints: Vec<SourceBreakpoint>, ) -> Result<Vec<Breakpoint>>
Set breakpoints for a source file
Sourcepub async fn set_function_breakpoints(
&mut self,
breakpoints: Vec<FunctionBreakpoint>,
) -> Result<Vec<Breakpoint>>
pub async fn set_function_breakpoints( &mut self, breakpoints: Vec<FunctionBreakpoint>, ) -> Result<Vec<Breakpoint>>
Set function breakpoints
Sourcepub async fn continue_execution(&mut self, thread_id: i64) -> Result<bool>
pub async fn continue_execution(&mut self, thread_id: i64) -> Result<bool>
Continue execution
Sourcepub async fn stack_trace(
&mut self,
thread_id: i64,
levels: i64,
) -> Result<Vec<StackFrame>>
pub async fn stack_trace( &mut self, thread_id: i64, levels: i64, ) -> Result<Vec<StackFrame>>
Get stack trace
Sourcepub async fn variables(
&mut self,
variables_reference: i64,
) -> Result<Vec<Variable>>
pub async fn variables( &mut self, variables_reference: i64, ) -> Result<Vec<Variable>>
Get variables
Sourcepub async fn evaluate(
&mut self,
expression: &str,
frame_id: Option<i64>,
context: &str,
) -> Result<EvaluateResponseBody>
pub async fn evaluate( &mut self, expression: &str, frame_id: Option<i64>, context: &str, ) -> Result<EvaluateResponseBody>
Evaluate an expression
Sourcepub async fn disconnect(&mut self, terminate_debuggee: bool) -> Result<()>
pub async fn disconnect(&mut self, terminate_debuggee: bool) -> Result<()>
Disconnect from the debug adapter
Sourcepub async fn terminate(&mut self) -> Result<()>
pub async fn terminate(&mut self) -> Result<()>
Terminate the adapter process and clean up resources
Sourcepub fn is_running(&mut self) -> bool
pub fn is_running(&mut self) -> bool
Check if the adapter is still running
Trait Implementations§
Source§impl Drop for DapClient
impl Drop for DapClient
Source§fn drop(&mut self)
fn drop(&mut self)
Best-effort cleanup on drop.
§Limitations
Since we can’t await in drop(), this is necessarily imperfect:
try_sendmay fail if the shutdown channel is full (unlikely with capacity 1)task.abort()is immediate; the reader may be mid-operationstart_kill()is non-blocking; the adapter may not exit immediately
For graceful cleanup, prefer calling terminate() before dropping.
This Drop impl exists as a safety net to avoid leaking resources if
terminate() wasn’t called.
Auto Trait Implementations§
impl !Freeze for DapClient
impl !RefUnwindSafe for DapClient
impl Send for DapClient
impl Sync for DapClient
impl Unpin for DapClient
impl !UnwindSafe for DapClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more