bsp_types/
bt_test.rs

1use super::BuildTargetIdentifier;
2use serde::{Deserialize, Serialize};
3use serde_json::Value;
4
5/// The test build target request is sent from the client to the server to test the given list of
6/// build targets. The server communicates during the initialize handshake whether this method is
7/// supported or not.
8#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
9#[serde(rename_all = "camelCase")]
10pub struct BuildTargetTest {
11    /// The build target to run.
12    target: BuildTargetIdentifier,
13
14    /// A unique identifier generated by the client to identify this request.
15    ///  * The server may include this id in triggered notifications or responses.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    origin_id: Option<String>,
18
19    /// Optional arguments to the executed application.
20    #[serde(skip_serializing_if = "Option::is_none")]
21    arguments: Option<String>,
22
23    /// Kind of data to expect in the data field. If this field is not set, the kind of data is not specified.
24    #[serde(skip_serializing_if = "Option::is_none")]
25    data_kind: Option<String>,
26
27    /// Language-specific metadata for this execution.
28    ///  * See <https://github.com/build-server-protocol/build-server-protocol/blob/9dce5849816483b5b0a2baed24f83bf101546184/bsp4j/src/main/xtend-gen/ch/epfl/scala/bsp4j/ScalaTestParams.java>
29    #[serde(skip_serializing_if = "Option::is_none")]
30    data: Option<Value>,
31}
32
33impl BuildTargetTest {
34    pub fn new(
35        target: BuildTargetIdentifier,
36        origin_id: Option<String>,
37        arguments: Option<String>,
38        data_kind: Option<String>,
39        data: Option<Value>,
40    ) -> Self {
41        Self {
42            target,
43            origin_id,
44            arguments,
45            data_kind,
46            data,
47        }
48    }
49    pub fn new_simple(target: BuildTargetIdentifier) -> Self {
50        Self {
51            target,
52            origin_id: None,
53            arguments: None,
54            data_kind: None,
55            data: None,
56        }
57    }
58
59    /// Get a reference to the bsp btrun params's target.
60    pub fn target(&self) -> &BuildTargetIdentifier {
61        &self.target
62    }
63
64    /// Set the bsp btrun params's target.
65    pub fn set_target(&mut self, target: BuildTargetIdentifier) {
66        self.target = target;
67    }
68
69    /// Get a reference to the bsp btrun params's origin id.
70    pub fn origin_id(&self) -> Option<&String> {
71        self.origin_id.as_ref()
72    }
73
74    /// Set the bsp btrun params's origin id.
75    pub fn set_origin_id(&mut self, origin_id: Option<String>) {
76        self.origin_id = origin_id;
77    }
78
79    /// Get a reference to the bsp btrun params's arguments.
80    pub fn arguments(&self) -> Option<&String> {
81        self.arguments.as_ref()
82    }
83
84    /// Set the bsp btrun params's arguments.
85    pub fn set_arguments(&mut self, arguments: Option<String>) {
86        self.arguments = arguments;
87    }
88
89    /// Get a reference to the bsp btrun params's data kind.
90    pub fn data_kind(&self) -> Option<&String> {
91        self.data_kind.as_ref()
92    }
93
94    /// Set the bsp btrun params's data kind.
95    pub fn set_data_kind(&mut self, data_kind: Option<String>) {
96        self.data_kind = data_kind;
97    }
98
99    /// Get a reference to the bsp btrun params's data.
100    pub fn data(&self) -> Option<&Value> {
101        self.data.as_ref()
102    }
103
104    /// Set the bsp btrun params's data.
105    pub fn set_data(&mut self, data: Option<Value>) {
106        self.data = data;
107    }
108}
109
110/// Note that an empty run request is valid. Run will be executed in the target as specified in the build tool.
111#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
112#[serde(rename_all = "camelCase")]
113pub struct BuildTargetTestResult {
114    /// An optional request id to know the origin of this report.
115    #[serde(skip_serializing_if = "Option::is_none")]
116    origin_id: Option<String>,
117
118    /// A status code for the execution.
119    status_code: usize,
120
121    /// Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified.
122    #[serde(skip_serializing_if = "Option::is_none")]
123    data_kind: Option<String>,
124
125    /// A field containing language-specific information, like products
126    ///    * of compilation or compiler-specific metadata the client needs to know.
127    #[serde(skip_serializing_if = "Option::is_none")]
128    data: Option<Value>,
129}
130
131impl BuildTargetTestResult {
132    pub fn new(
133        origin_id: Option<String>,
134        status_code: usize,
135        data_kind: Option<String>,
136        data: Option<Value>,
137    ) -> Self {
138        Self {
139            origin_id,
140            status_code,
141            data_kind,
142            data,
143        }
144    }
145    pub fn new_simple(status_code: usize) -> Self {
146        Self {
147            origin_id: None,
148            status_code,
149            data_kind: None,
150            data: None,
151        }
152    }
153
154    /// Get a reference to the bsp btrun result's origin id.
155    pub fn origin_id(&self) -> Option<&String> {
156        self.origin_id.as_ref()
157    }
158
159    /// Get the bsp btrun result's status code.
160    pub fn status_code(&self) -> usize {
161        self.status_code
162    }
163
164    /// Set the bsp btrun result's origin id.
165    pub fn set_origin_id(&mut self, origin_id: Option<String>) {
166        self.origin_id = origin_id;
167    }
168
169    /// Set the bsp btrun result's status code.
170    pub fn set_status_code(&mut self, status_code: usize) {
171        self.status_code = status_code;
172    }
173
174    /// Set the bsp btcompile result's data kind.
175    pub fn set_data_kind(&mut self, data_kind: Option<String>) {
176        self.data_kind = data_kind;
177    }
178
179    /// Get a reference to the bsp btcompile result's data kind.
180    pub fn data_kind(&self) -> Option<&String> {
181        self.data_kind.as_ref()
182    }
183
184    /// Set the bsp btcompile result's data.
185    pub fn set_data(&mut self, data: Option<Value>) {
186        self.data = data;
187    }
188
189    /// Get a reference to the bsp btcompile result's data.
190    pub fn data(&self) -> Option<&Value> {
191        self.data.as_ref()
192    }
193}