Skip to main content

subspace_core/diagnostics/
issue.rs

1use super::{BuildIdentity, IssuePaths};
2
3/// Issue-only allowlist. Paths require a separately sanitized, explicit opt-in
4/// projection; this type cannot receive local errors, logs or runtime state.
5#[derive(Debug, Clone)]
6pub struct IssueDiagnostics {
7    identity: BuildIdentity,
8    active_board: Option<String>,
9    theme_id: Option<String>,
10    icon_size: Option<String>,
11    paths: Option<IssuePaths>,
12}
13
14// qual:allow(dry, boilerplate) reason: "The issue projection accepts shared registered identities and explicitly excludes every local field; no conversion dependency is needed for this small allowlist."
15impl From<BuildIdentity> for IssueDiagnostics {
16    fn from(identity: BuildIdentity) -> Self {
17        Self {
18            identity,
19            active_board: None,
20            theme_id: None,
21            icon_size: None,
22            paths: None,
23        }
24    }
25}
26
27// qual:allow(dry, boilerplate) reason: "Preserve the existing issue Diagnostics builder API while keeping its fields private and its allowlist unchanged; a builder dependency would add no behavior."
28impl IssueDiagnostics {
29    pub fn new(product_id: impl Into<String>, app_version: impl Into<String>) -> Self {
30        BuildIdentity::new(product_id, app_version).into()
31    }
32
33    pub fn with_build(mut self, channel: impl Into<String>, commit: impl Into<String>) -> Self {
34        self.identity = self.identity.with_build(channel, commit);
35        self
36    }
37
38    pub fn with_platform(mut self, os: impl Into<String>, architecture: impl Into<String>) -> Self {
39        self.identity = self.identity.with_platform(os, architecture);
40        self
41    }
42
43    pub fn with_active_board(mut self, id: impl Into<String>) -> Self {
44        self.active_board = Some(id.into());
45        self
46    }
47
48    pub fn with_appearance(
49        mut self,
50        theme_id: impl Into<String>,
51        icon_size: impl Into<String>,
52    ) -> Self {
53        self.theme_id = Some(theme_id.into());
54        self.icon_size = Some(icon_size.into());
55        self
56    }
57
58    pub fn with_paths(mut self, paths: IssuePaths) -> Self {
59        self.paths = Some(paths);
60        self
61    }
62
63    pub fn without_paths(mut self) -> Self {
64        self.paths = None;
65        self
66    }
67
68    pub fn paths(&self) -> Option<&IssuePaths> {
69        self.paths.as_ref()
70    }
71
72    pub fn product_id(&self) -> &str {
73        self.identity.product_id()
74    }
75
76    pub fn app_version(&self) -> &str {
77        self.identity.app_version()
78    }
79
80    pub fn channel(&self) -> Option<&str> {
81        self.identity.channel()
82    }
83
84    pub fn commit(&self) -> Option<&str> {
85        self.identity.commit()
86    }
87
88    pub fn os(&self) -> Option<&str> {
89        self.identity.os()
90    }
91
92    pub fn architecture(&self) -> Option<&str> {
93        self.identity.architecture()
94    }
95
96    pub fn active_board(&self) -> Option<&str> {
97        self.active_board.as_deref()
98    }
99
100    pub fn theme_id(&self) -> Option<&str> {
101        self.theme_id.as_deref()
102    }
103
104    /// Semantic global size key, not physical pixels or a resolved glyph size.
105    pub fn icon_size(&self) -> Option<&str> {
106        self.icon_size.as_deref()
107    }
108}