Skip to main content

synwire_dap/
config.rs

1//! Configuration types for the DAP plugin and adapter processes.
2
3use std::collections::HashMap;
4
5use serde::{Deserialize, Serialize};
6
7/// Configuration for spawning a debug adapter process.
8#[derive(Debug, Clone, Serialize, Deserialize)]
9#[non_exhaustive]
10pub struct DapAdapterConfig {
11    /// Path or name of the adapter binary.
12    pub command: String,
13    /// Command-line arguments passed to the adapter.
14    pub args: Vec<String>,
15    /// Additional environment variables for the adapter process.
16    pub env: HashMap<String, String>,
17}
18
19impl DapAdapterConfig {
20    /// Create a new adapter configuration.
21    #[must_use]
22    pub fn new(command: impl Into<String>) -> Self {
23        Self {
24            command: command.into(),
25            args: Vec::new(),
26            env: HashMap::new(),
27        }
28    }
29
30    /// Add command-line arguments.
31    #[must_use]
32    pub fn with_args(mut self, args: Vec<String>) -> Self {
33        self.args = args;
34        self
35    }
36
37    /// Add environment variables.
38    #[must_use]
39    pub fn with_env(mut self, env: HashMap<String, String>) -> Self {
40        self.env = env;
41        self
42    }
43}
44
45/// Configuration for the DAP plugin behaviour.
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[non_exhaustive]
48pub struct DapPluginConfig {
49    /// Whether to automatically disconnect/shutdown adapters when the agent stops.
50    pub auto_shutdown: bool,
51}
52
53impl Default for DapPluginConfig {
54    fn default() -> Self {
55        Self {
56            auto_shutdown: true,
57        }
58    }
59}