bsp_types/
debug_session_start.rs

1use super::BuildTargetIdentifier;
2use lsp_types::Url;
3use serde::{Deserialize, Serialize};
4use serde_json::Value;
5
6/// The debug request is sent from the client to the server to debug build target(s). The server
7/// launches a Microsoft DAP server and returns a connection URI for the client to interact with.
8#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
9#[serde(rename_all = "camelCase", default)]
10pub struct DebugSessionStart {
11    /// A sequence of build targets affected by the debugging action.
12    targets: Vec<BuildTargetIdentifier>,
13
14    /// The kind of data to expect in the `data` field.
15    /// TODO: Is DebugSessionStart dataKind == TaskDataKind?
16    data_kind: String,
17
18    /// Language-specific metadata for this execution.
19    ///  * See <https://github.com/build-server-protocol/build-server-protocol/blob/master/bsp4j/src/main/xtend-gen/ch/epfl/scala/bsp4j/ScalaMainClass.java>
20    #[serde(skip_serializing_if = "Value::is_null")]
21    data: Value,
22}
23
24impl DebugSessionStart {
25    pub fn new(targets: Vec<BuildTargetIdentifier>, data_kind: String, data: Value) -> Self {
26        Self {
27            targets,
28            data_kind,
29            data,
30        }
31    }
32
33    /// Get a reference to the debug session params's targets.
34    pub fn targets(&self) -> &[BuildTargetIdentifier] {
35        self.targets.as_ref()
36    }
37
38    /// Get a reference to the debug session params's data kind.
39    pub fn data_kind(&self) -> &str {
40        self.data_kind.as_ref()
41    }
42
43    /// Get a reference to the debug session params's data.
44    pub fn data(&self) -> &Value {
45        &self.data
46    }
47
48    /// Set the debug session params's targets.
49    pub fn set_targets(&mut self, targets: Vec<BuildTargetIdentifier>) {
50        self.targets = targets;
51    }
52
53    /// Set the debug session params's data kind.
54    pub fn set_data_kind(&mut self, data_kind: String) {
55        self.data_kind = data_kind;
56    }
57
58    /// Set the debug session params's data.
59    pub fn set_data(&mut self, data: Value) {
60        self.data = data;
61    }
62}
63
64#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
65pub struct DebugSessionStartResult {
66    /** The Debug Adapter Protocol server's connection uri */
67    uri: Url,
68}
69
70impl DebugSessionStartResult {
71    pub fn new(uri: Url) -> Self {
72        Self { uri }
73    }
74}