Skip to main content

subspace_core/diagnostics/
identity.rs

1/// Registered build and platform identities shared by both diagnostics profiles.
2/// Values must be product/build identifiers, never user-configured names.
3#[derive(Debug, Clone)]
4pub struct BuildIdentity {
5    product_id: String,
6    app_version: String,
7    channel: Option<String>,
8    commit: Option<String>,
9    os: Option<String>,
10    architecture: Option<String>,
11}
12
13impl BuildIdentity {
14    pub fn new(product_id: impl Into<String>, app_version: impl Into<String>) -> Self {
15        Self {
16            product_id: product_id.into(),
17            app_version: app_version.into(),
18            channel: None,
19            commit: None,
20            os: None,
21            architecture: None,
22        }
23    }
24
25    pub fn with_build(mut self, channel: impl Into<String>, commit: impl Into<String>) -> Self {
26        self.channel = Some(channel.into());
27        self.commit = Some(commit.into());
28        self
29    }
30
31    pub fn with_platform(mut self, os: impl Into<String>, architecture: impl Into<String>) -> Self {
32        self.os = Some(os.into());
33        self.architecture = Some(architecture.into());
34        self
35    }
36
37    pub fn product_id(&self) -> &str {
38        &self.product_id
39    }
40
41    pub fn app_version(&self) -> &str {
42        &self.app_version
43    }
44
45    pub fn channel(&self) -> Option<&str> {
46        self.channel.as_deref()
47    }
48
49    pub fn commit(&self) -> Option<&str> {
50        self.commit.as_deref()
51    }
52
53    pub fn os(&self) -> Option<&str> {
54        self.os.as_deref()
55    }
56
57    pub fn architecture(&self) -> Option<&str> {
58        self.architecture.as_deref()
59    }
60}