From 780bfafedf7a1f775602a6d4642d9d4d4ac18f57 Mon Sep 17 00:00:00 2001 From: Anthony Eid Date: Tue, 23 Jul 2024 02:56:20 -0400 Subject: [PATCH] Add some function docs to dap client --- crates/dap/src/client.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/crates/dap/src/client.rs b/crates/dap/src/client.rs index 741f840f9fe02..e8607c317b8bf 100644 --- a/crates/dap/src/client.rs +++ b/crates/dap/src/client.rs @@ -72,6 +72,15 @@ pub struct DebugAdapterClient { } impl DebugAdapterClient { + /// Creates & returns a new debug adapter client + /// + /// # Parameters + /// - `id`: The id that [`Project`](project::Project) uses to keep track of specific clients + /// - `config`: The adapter specific configurations from debugger task that is starting + /// - `command`: The command that starts the debugger + /// - `args`: Arguments of the command that starts the debugger + /// - `project_path`: The absolute path of the project that is being debugged + /// - `cx`: The context that the new client belongs too pub async fn new( id: DebugAdapterClientId, config: DebugAdapterConfig, @@ -90,6 +99,17 @@ impl DebugAdapterClient { } } + /// Creates a debug client that connects to an adapter through tcp + /// + /// TCP clients don't have an error communication stream with an adapter + /// + /// # Parameters + /// - `id`: The id that [`Project`](project::Project) uses to keep track of specific clients + /// - `config`: The adapter specific configurations from debugger task that is starting + /// - `command`: The command that starts the debugger + /// - `args`: Arguments of the command that starts the debugger + /// - `project_path`: The absolute path of the project that is being debugged + /// - `cx`: The context that the new client belongs too async fn create_tcp_client( id: DebugAdapterClientId, config: DebugAdapterConfig, @@ -143,6 +163,7 @@ impl DebugAdapterClient { ) } + /// Get an open port to use with the tcp client when not supplied by debug config async fn get_port() -> Option { Some( TcpListener::bind(SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 0)) @@ -154,6 +175,15 @@ impl DebugAdapterClient { ) } + /// Creates a debug client that connects to an adapter through std input/output + /// + /// # Parameters + /// - `id`: The id that [`Project`](project::Project) uses to keep track of specific clients + /// - `config`: The adapter specific configurations from debugger task that is starting + /// - `command`: The command that starts the debugger + /// - `args`: Arguments of the command that starts the debugger + /// - `project_path`: The absolute path of the project that is being debugged + /// - `cx`: The context that the new client belongs too async fn create_stdio_client( id: DebugAdapterClientId, config: DebugAdapterConfig, @@ -226,6 +256,14 @@ impl DebugAdapterClient { Ok(client) } + /// Set's up a client's event handler. + /// + /// This function should only be called once or else errors will arise + /// # Parameters + /// `client`: A pointer to the client to pass the event handler too + /// `event_handler`: The function that is called to handle events + /// should be DebugPanel::handle_debug_client_events + /// `cx`: The context that this task will run in pub async fn handle_events( client: Arc, mut event_handler: F, @@ -258,6 +296,8 @@ impl DebugAdapterClient { } } + /// Send a request to an adapter and get a response back + /// Note: This function will block until a response is sent back from the adapter pub async fn request( &self, arguments: R::Arguments,