bsp_types/
bt_compile.rs

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