bsp_types/
bt_did_change.rs

1use super::BuildTargetIdentifier;
2use serde::{Deserialize, Serialize};
3
4/// The build target changed notification is sent from the server to the client
5/// to signal a change in a build target. The server communicates during the
6/// initialize handshake whether this method is supported or not.
7#[derive(Default, Debug, Serialize, Deserialize, Clone)]
8pub struct BuildTargetDidChange {
9    pub changes: Vec<BuildTargetEvent>,
10}
11
12impl BuildTargetDidChange {
13    pub const METHOD: &'static str = "buildTarget/didChange";
14}
15
16#[derive(Debug, Serialize, Deserialize, Clone)]
17pub struct BuildTargetEvent {
18    /// The identifier for the changed build target.
19    pub target: BuildTargetIdentifier,
20    /// The kind of change for this build target.
21    #[serde(skip_serializing_if = "Option::is_none")]
22    pub kind: Option<BuildTargetEventKind>,
23    /// Any additional metadata about what information changed.
24    #[serde(skip_serializing_if = "Option::is_none")]
25    pub data: Option<serde_json::Value>,
26}
27
28impl BuildTargetEvent {
29    pub fn new(
30        target: BuildTargetIdentifier,
31        kind: Option<BuildTargetEventKind>,
32        data: Option<serde_json::Value>,
33    ) -> Self {
34        Self { target, kind, data }
35    }
36    pub fn new_simple(target: BuildTargetIdentifier) -> Self {
37        Self {
38            target,
39            kind: Default::default(),
40            data: Default::default(),
41        }
42    }
43}
44
45#[derive(Clone, Debug, serde_repr::Deserialize_repr, serde_repr::Serialize_repr)]
46#[repr(u16)]
47pub enum BuildTargetEventKind {
48    /// The build target is new (default).
49    Created = 1,
50    /// The build target has changed.
51    Changed = 2,
52    /// The build target has been deleted.
53    Deleted = 3,
54}
55
56impl Default for BuildTargetEventKind {
57    fn default() -> Self {
58        Self::Created
59    }
60}