Skip to main content

browser_protocol/systeminfo/
mod.rs

1//! The SystemInfo domain defines methods and events for querying low-level system information.
2use serde::{Serialize, Deserialize};
3use serde_json::Value as JsonValue;
4
5/// Describes a single graphics processor (GPU).
6
7#[derive(Debug, Clone, Serialize, Deserialize, Default)]
8#[serde(rename_all = "camelCase")]
9pub struct GPUDevice {
10    /// PCI ID of the GPU vendor, if available; 0 otherwise.
11
12    pub vendorId: f64,
13    /// PCI ID of the GPU device, if available; 0 otherwise.
14
15    pub deviceId: f64,
16    /// Sub sys ID of the GPU, only available on Windows.
17
18    #[serde(skip_serializing_if = "Option::is_none")]
19    pub subSysId: Option<f64>,
20    /// Revision of the GPU, only available on Windows.
21
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub revision: Option<f64>,
24    /// String description of the GPU vendor, if the PCI ID is not available.
25
26    pub vendorString: String,
27    /// String description of the GPU device, if the PCI ID is not available.
28
29    pub deviceString: String,
30    /// String description of the GPU driver vendor.
31
32    pub driverVendor: String,
33    /// String description of the GPU driver version.
34
35    pub driverVersion: String,
36}
37
38/// Describes the width and height dimensions of an entity.
39
40#[derive(Debug, Clone, Serialize, Deserialize, Default)]
41#[serde(rename_all = "camelCase")]
42pub struct Size {
43    /// Width in pixels.
44
45    pub width: u64,
46    /// Height in pixels.
47
48    pub height: i64,
49}
50
51/// Describes a supported video decoding profile with its associated minimum and
52/// maximum resolutions.
53
54#[derive(Debug, Clone, Serialize, Deserialize, Default)]
55#[serde(rename_all = "camelCase")]
56pub struct VideoDecodeAcceleratorCapability {
57    /// Video codec profile that is supported, e.g. VP9 Profile 2.
58
59    pub profile: String,
60    /// Maximum video dimensions in pixels supported for this |profile|.
61
62    pub maxResolution: Size,
63    /// Minimum video dimensions in pixels supported for this |profile|.
64
65    pub minResolution: Size,
66}
67
68/// Describes a supported video encoding profile with its associated maximum
69/// resolution and maximum framerate.
70
71#[derive(Debug, Clone, Serialize, Deserialize, Default)]
72#[serde(rename_all = "camelCase")]
73pub struct VideoEncodeAcceleratorCapability {
74    /// Video codec profile that is supported, e.g H264 Main.
75
76    pub profile: String,
77    /// Maximum video dimensions in pixels supported for this |profile|.
78
79    pub maxResolution: Size,
80    /// Maximum encoding framerate in frames per second supported for this
81    /// |profile|, as fraction's numerator and denominator, e.g. 24/1 fps,
82    /// 24000/1001 fps, etc.
83
84    pub maxFramerateNumerator: i64,
85
86    pub maxFramerateDenominator: i64,
87}
88
89/// YUV subsampling type of the pixels of a given image.
90
91#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
92pub enum SubsamplingFormat {
93    #[default]
94    Yuv420,
95    Yuv422,
96    Yuv444,
97}
98
99/// Image format of a given image.
100
101#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
102pub enum ImageType {
103    #[default]
104    Jpeg,
105    Webp,
106    Unknown,
107}
108
109/// Provides information about the GPU(s) on the system.
110
111#[derive(Debug, Clone, Serialize, Deserialize, Default)]
112#[serde(rename_all = "camelCase")]
113pub struct GPUInfo {
114    /// The graphics devices on the system. Element 0 is the primary GPU.
115
116    pub devices: Vec<GPUDevice>,
117    /// An optional dictionary of additional GPU related attributes.
118
119    #[serde(skip_serializing_if = "Option::is_none")]
120    pub auxAttributes: Option<serde_json::Map<String, JsonValue>>,
121    /// An optional dictionary of graphics features and their status.
122
123    #[serde(skip_serializing_if = "Option::is_none")]
124    pub featureStatus: Option<serde_json::Map<String, JsonValue>>,
125    /// An optional array of GPU driver bug workarounds.
126
127    pub driverBugWorkarounds: Vec<String>,
128    /// Supported accelerated video decoding capabilities.
129
130    pub videoDecoding: Vec<VideoDecodeAcceleratorCapability>,
131    /// Supported accelerated video encoding capabilities.
132
133    pub videoEncoding: Vec<VideoEncodeAcceleratorCapability>,
134}
135
136/// Represents process info.
137
138#[derive(Debug, Clone, Serialize, Deserialize, Default)]
139#[serde(rename_all = "camelCase")]
140pub struct ProcessInfo {
141    /// Specifies process type.
142
143    #[serde(rename = "type")]
144    pub type_: String,
145    /// Specifies process id.
146
147    pub id: u64,
148    /// Specifies cumulative CPU usage in seconds across all threads of the
149    /// process since the process start.
150
151    pub cpuTime: f64,
152}
153
154/// Returns information about the system.
155
156#[derive(Debug, Clone, Serialize, Deserialize, Default)]
157#[serde(rename_all = "camelCase")]
158pub struct GetInfoReturns {
159    /// Information about the GPUs on the system.
160
161    pub gpu: GPUInfo,
162    /// A platform-dependent description of the model of the machine. On Mac OS, this is, for
163    /// example, 'MacBookPro'. Will be the empty string if not supported.
164
165    pub modelName: String,
166    /// A platform-dependent description of the version of the machine. On Mac OS, this is, for
167    /// example, '10.1'. Will be the empty string if not supported.
168
169    pub modelVersion: String,
170    /// The command line string used to launch the browser. Will be the empty string if not
171    /// supported.
172
173    pub commandLine: String,
174}
175
176#[derive(Debug, Clone, Serialize, Deserialize, Default)]
177pub struct GetInfoParams {}
178
179impl GetInfoParams { pub const METHOD: &'static str = "SystemInfo.getInfo"; }
180
181impl crate::CdpCommand for GetInfoParams {
182    const METHOD: &'static str = "SystemInfo.getInfo";
183    type Response = GetInfoReturns;
184}
185
186/// Returns information about the feature state.
187
188#[derive(Debug, Clone, Serialize, Deserialize, Default)]
189#[serde(rename_all = "camelCase")]
190pub struct GetFeatureStateParams {
191
192    pub featureState: String,
193}
194
195/// Returns information about the feature state.
196
197#[derive(Debug, Clone, Serialize, Deserialize, Default)]
198#[serde(rename_all = "camelCase")]
199pub struct GetFeatureStateReturns {
200
201    pub featureEnabled: bool,
202}
203
204impl GetFeatureStateParams { pub const METHOD: &'static str = "SystemInfo.getFeatureState"; }
205
206impl crate::CdpCommand for GetFeatureStateParams {
207    const METHOD: &'static str = "SystemInfo.getFeatureState";
208    type Response = GetFeatureStateReturns;
209}
210
211/// Returns information about all running processes.
212
213#[derive(Debug, Clone, Serialize, Deserialize, Default)]
214#[serde(rename_all = "camelCase")]
215pub struct GetProcessInfoReturns {
216    /// An array of process info blocks.
217
218    pub processInfo: Vec<ProcessInfo>,
219}
220
221#[derive(Debug, Clone, Serialize, Deserialize, Default)]
222pub struct GetProcessInfoParams {}
223
224impl GetProcessInfoParams { pub const METHOD: &'static str = "SystemInfo.getProcessInfo"; }
225
226impl crate::CdpCommand for GetProcessInfoParams {
227    const METHOD: &'static str = "SystemInfo.getProcessInfo";
228    type Response = GetProcessInfoReturns;
229}