bsp_types/
initialize_result.rs

1use super::ServerCapabilities;
2use serde::{Deserialize, Serialize};
3use serde_json::Value;
4
5/// Initialize Build response result
6#[derive(Default, Debug, Serialize, Deserialize)]
7#[serde(rename_all = "camelCase")]
8pub struct InitializeBuildResult {
9    /// Name of the server
10    display_name: String,
11    /// The version of the server
12    version: String,
13    /// The BSP version that the server speaks
14    bsp_version: String,
15    /// The capabilities of the build server
16    capabilities: ServerCapabilities,
17    /// Optional metadata about the server
18    #[serde(skip_serializing_if = "Option::is_none")]
19    data: Option<Value>,
20}
21
22impl InitializeBuildResult {
23    pub fn new<S: Into<String>>(
24        display_name: S,
25        version: S,
26        bsp_version: S,
27        capabilities: ServerCapabilities,
28        data: Value,
29    ) -> Self {
30        Self {
31            display_name: display_name.into(),
32            version: version.into(),
33            bsp_version: bsp_version.into(),
34            capabilities,
35            data: data.into(),
36        }
37    }
38
39    pub fn new_simple<S: Into<String>>(
40        display_name: S,
41        version: S,
42        bsp_version: S,
43        capabilities: ServerCapabilities,
44    ) -> Self {
45        Self {
46            display_name: display_name.into(),
47            version: version.into(),
48            bsp_version: bsp_version.into(),
49            capabilities,
50            data: None,
51        }
52    }
53
54    /// Set the bsp initialize build result's bsp version.
55    pub fn set_bsp_version(&mut self, bsp_version: String) {
56        self.bsp_version = bsp_version;
57    }
58
59    /// Get a reference to the bsp initialize build result's bsp version.
60    pub fn bsp_version(&self) -> &str {
61        self.bsp_version.as_ref()
62    }
63
64    /// Set the bsp initialize build result's version.
65    pub fn set_version(&mut self, version: String) {
66        self.version = version;
67    }
68
69    /// Get a reference to the bsp initialize build result's version.
70    pub fn version(&self) -> &str {
71        self.version.as_ref()
72    }
73
74    /// Set the bsp initialize build result's display name.
75    pub fn set_display_name(&mut self, display_name: String) {
76        self.display_name = display_name;
77    }
78
79    /// Get a reference to the bsp initialize build result's display name.
80    pub fn display_name(&self) -> &str {
81        self.display_name.as_ref()
82    }
83
84    /// Set the bsp initialize build result's capabilities.
85    pub fn set_capabilities(&mut self, capabilities: ServerCapabilities) {
86        self.capabilities = capabilities;
87    }
88
89    /// Get a reference to the bsp initialize build result's capabilities.
90    pub fn capabilities(&self) -> &ServerCapabilities {
91        &self.capabilities
92    }
93
94    /// Set the bsp initialize build result's data.
95    pub fn set_data(&mut self, data: Option<Value>) {
96        self.data = data;
97    }
98
99    /// Get a reference to the bsp initialize build result's data.
100    pub fn data(&self) -> Option<&Value> {
101        self.data.as_ref()
102    }
103
104    /// Get a mutable reference to the bsp initialize build result's data.
105    pub fn data_mut(&mut self) -> &mut Option<Value> {
106        &mut self.data
107    }
108}