1use serde::{Serialize, Deserialize};
5use serde_json::Value as JsonValue;
6use std::borrow::Cow;
7
8#[derive(Debug, Clone, Serialize, Deserialize, Default)]
11#[serde(rename_all = "camelCase")]
12pub struct GPUDevice<'a> {
13 #[serde(rename = "vendorId")]
15 vendor_id: f64,
16 #[serde(rename = "deviceId")]
18 device_id: f64,
19 #[serde(skip_serializing_if = "Option::is_none", rename = "subSysId")]
21 sub_sys_id: Option<f64>,
22 #[serde(skip_serializing_if = "Option::is_none")]
24 revision: Option<f64>,
25 #[serde(rename = "vendorString")]
27 vendor_string: Cow<'a, str>,
28 #[serde(rename = "deviceString")]
30 device_string: Cow<'a, str>,
31 #[serde(rename = "driverVendor")]
33 driver_vendor: Cow<'a, str>,
34 #[serde(rename = "driverVersion")]
36 driver_version: Cow<'a, str>,
37}
38
39impl<'a> GPUDevice<'a> {
40 pub fn builder(vendor_id: f64, device_id: f64, vendor_string: impl Into<Cow<'a, str>>, device_string: impl Into<Cow<'a, str>>, driver_vendor: impl Into<Cow<'a, str>>, driver_version: impl Into<Cow<'a, str>>) -> GPUDeviceBuilder<'a> {
48 GPUDeviceBuilder {
49 vendor_id: vendor_id,
50 device_id: device_id,
51 sub_sys_id: None,
52 revision: None,
53 vendor_string: vendor_string.into(),
54 device_string: device_string.into(),
55 driver_vendor: driver_vendor.into(),
56 driver_version: driver_version.into(),
57 }
58 }
59 pub fn vendor_id(&self) -> f64 { self.vendor_id }
61 pub fn device_id(&self) -> f64 { self.device_id }
63 pub fn sub_sys_id(&self) -> Option<f64> { self.sub_sys_id }
65 pub fn revision(&self) -> Option<f64> { self.revision }
67 pub fn vendor_string(&self) -> &str { self.vendor_string.as_ref() }
69 pub fn device_string(&self) -> &str { self.device_string.as_ref() }
71 pub fn driver_vendor(&self) -> &str { self.driver_vendor.as_ref() }
73 pub fn driver_version(&self) -> &str { self.driver_version.as_ref() }
75}
76
77
78pub struct GPUDeviceBuilder<'a> {
79 vendor_id: f64,
80 device_id: f64,
81 sub_sys_id: Option<f64>,
82 revision: Option<f64>,
83 vendor_string: Cow<'a, str>,
84 device_string: Cow<'a, str>,
85 driver_vendor: Cow<'a, str>,
86 driver_version: Cow<'a, str>,
87}
88
89impl<'a> GPUDeviceBuilder<'a> {
90 pub fn sub_sys_id(mut self, sub_sys_id: f64) -> Self { self.sub_sys_id = Some(sub_sys_id); self }
92 pub fn revision(mut self, revision: f64) -> Self { self.revision = Some(revision); self }
94 pub fn build(self) -> GPUDevice<'a> {
95 GPUDevice {
96 vendor_id: self.vendor_id,
97 device_id: self.device_id,
98 sub_sys_id: self.sub_sys_id,
99 revision: self.revision,
100 vendor_string: self.vendor_string,
101 device_string: self.device_string,
102 driver_vendor: self.driver_vendor,
103 driver_version: self.driver_version,
104 }
105 }
106}
107
108#[derive(Debug, Clone, Serialize, Deserialize, Default)]
111#[serde(rename_all = "camelCase")]
112pub struct Size {
113 width: u64,
115 height: i64,
117}
118
119impl Size {
120 pub fn builder(width: u64, height: i64) -> SizeBuilder {
124 SizeBuilder {
125 width: width,
126 height: height,
127 }
128 }
129 pub fn width(&self) -> u64 { self.width }
131 pub fn height(&self) -> i64 { self.height }
133}
134
135
136pub struct SizeBuilder {
137 width: u64,
138 height: i64,
139}
140
141impl SizeBuilder {
142 pub fn build(self) -> Size {
143 Size {
144 width: self.width,
145 height: self.height,
146 }
147 }
148}
149
150#[derive(Debug, Clone, Serialize, Deserialize, Default)]
154#[serde(rename_all = "camelCase")]
155pub struct VideoDecodeAcceleratorCapability<'a> {
156 profile: Cow<'a, str>,
158 #[serde(rename = "maxResolution")]
160 max_resolution: Size,
161 #[serde(rename = "minResolution")]
163 min_resolution: Size,
164}
165
166impl<'a> VideoDecodeAcceleratorCapability<'a> {
167 pub fn builder(profile: impl Into<Cow<'a, str>>, max_resolution: Size, min_resolution: Size) -> VideoDecodeAcceleratorCapabilityBuilder<'a> {
172 VideoDecodeAcceleratorCapabilityBuilder {
173 profile: profile.into(),
174 max_resolution: max_resolution,
175 min_resolution: min_resolution,
176 }
177 }
178 pub fn profile(&self) -> &str { self.profile.as_ref() }
180 pub fn max_resolution(&self) -> &Size { &self.max_resolution }
182 pub fn min_resolution(&self) -> &Size { &self.min_resolution }
184}
185
186
187pub struct VideoDecodeAcceleratorCapabilityBuilder<'a> {
188 profile: Cow<'a, str>,
189 max_resolution: Size,
190 min_resolution: Size,
191}
192
193impl<'a> VideoDecodeAcceleratorCapabilityBuilder<'a> {
194 pub fn build(self) -> VideoDecodeAcceleratorCapability<'a> {
195 VideoDecodeAcceleratorCapability {
196 profile: self.profile,
197 max_resolution: self.max_resolution,
198 min_resolution: self.min_resolution,
199 }
200 }
201}
202
203#[derive(Debug, Clone, Serialize, Deserialize, Default)]
207#[serde(rename_all = "camelCase")]
208pub struct VideoEncodeAcceleratorCapability<'a> {
209 profile: Cow<'a, str>,
211 #[serde(rename = "maxResolution")]
213 max_resolution: Size,
214 #[serde(rename = "maxFramerateNumerator")]
218 max_framerate_numerator: i64,
219 #[serde(rename = "maxFramerateDenominator")]
220 max_framerate_denominator: i64,
221}
222
223impl<'a> VideoEncodeAcceleratorCapability<'a> {
224 pub fn builder(profile: impl Into<Cow<'a, str>>, max_resolution: Size, max_framerate_numerator: i64, max_framerate_denominator: i64) -> VideoEncodeAcceleratorCapabilityBuilder<'a> {
230 VideoEncodeAcceleratorCapabilityBuilder {
231 profile: profile.into(),
232 max_resolution: max_resolution,
233 max_framerate_numerator: max_framerate_numerator,
234 max_framerate_denominator: max_framerate_denominator,
235 }
236 }
237 pub fn profile(&self) -> &str { self.profile.as_ref() }
239 pub fn max_resolution(&self) -> &Size { &self.max_resolution }
241 pub fn max_framerate_numerator(&self) -> i64 { self.max_framerate_numerator }
245 pub fn max_framerate_denominator(&self) -> i64 { self.max_framerate_denominator }
246}
247
248
249pub struct VideoEncodeAcceleratorCapabilityBuilder<'a> {
250 profile: Cow<'a, str>,
251 max_resolution: Size,
252 max_framerate_numerator: i64,
253 max_framerate_denominator: i64,
254}
255
256impl<'a> VideoEncodeAcceleratorCapabilityBuilder<'a> {
257 pub fn build(self) -> VideoEncodeAcceleratorCapability<'a> {
258 VideoEncodeAcceleratorCapability {
259 profile: self.profile,
260 max_resolution: self.max_resolution,
261 max_framerate_numerator: self.max_framerate_numerator,
262 max_framerate_denominator: self.max_framerate_denominator,
263 }
264 }
265}
266
267#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
270pub enum SubsamplingFormat {
271 #[default]
272 #[serde(rename = "yuv420")]
273 Yuv420,
274 #[serde(rename = "yuv422")]
275 Yuv422,
276 #[serde(rename = "yuv444")]
277 Yuv444,
278}
279
280#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
283pub enum ImageType {
284 #[default]
285 #[serde(rename = "jpeg")]
286 Jpeg,
287 #[serde(rename = "webp")]
288 Webp,
289 #[serde(rename = "unknown")]
290 Unknown,
291}
292
293#[derive(Debug, Clone, Serialize, Deserialize, Default)]
296#[serde(rename_all = "camelCase")]
297pub struct GPUInfo<'a> {
298 devices: Vec<GPUDevice<'a>>,
300 #[serde(skip_serializing_if = "Option::is_none", rename = "auxAttributes")]
302 aux_attributes: Option<serde_json::Map<String, JsonValue>>,
303 #[serde(skip_serializing_if = "Option::is_none", rename = "featureStatus")]
305 feature_status: Option<serde_json::Map<String, JsonValue>>,
306 #[serde(rename = "driverBugWorkarounds")]
308 driver_bug_workarounds: Vec<Cow<'a, str>>,
309 #[serde(rename = "videoDecoding")]
311 video_decoding: Vec<VideoDecodeAcceleratorCapability<'a>>,
312 #[serde(rename = "videoEncoding")]
314 video_encoding: Vec<VideoEncodeAcceleratorCapability<'a>>,
315}
316
317impl<'a> GPUInfo<'a> {
318 pub fn builder(devices: Vec<GPUDevice<'a>>, driver_bug_workarounds: Vec<Cow<'a, str>>, video_decoding: Vec<VideoDecodeAcceleratorCapability<'a>>, video_encoding: Vec<VideoEncodeAcceleratorCapability<'a>>) -> GPUInfoBuilder<'a> {
324 GPUInfoBuilder {
325 devices: devices,
326 aux_attributes: None,
327 feature_status: None,
328 driver_bug_workarounds: driver_bug_workarounds,
329 video_decoding: video_decoding,
330 video_encoding: video_encoding,
331 }
332 }
333 pub fn devices(&self) -> &[GPUDevice<'a>] { &self.devices }
335 pub fn aux_attributes(&self) -> Option<&serde_json::Map<String, JsonValue>> { self.aux_attributes.as_ref() }
337 pub fn feature_status(&self) -> Option<&serde_json::Map<String, JsonValue>> { self.feature_status.as_ref() }
339 pub fn driver_bug_workarounds(&self) -> &[Cow<'a, str>] { &self.driver_bug_workarounds }
341 pub fn video_decoding(&self) -> &[VideoDecodeAcceleratorCapability<'a>] { &self.video_decoding }
343 pub fn video_encoding(&self) -> &[VideoEncodeAcceleratorCapability<'a>] { &self.video_encoding }
345}
346
347
348pub struct GPUInfoBuilder<'a> {
349 devices: Vec<GPUDevice<'a>>,
350 aux_attributes: Option<serde_json::Map<String, JsonValue>>,
351 feature_status: Option<serde_json::Map<String, JsonValue>>,
352 driver_bug_workarounds: Vec<Cow<'a, str>>,
353 video_decoding: Vec<VideoDecodeAcceleratorCapability<'a>>,
354 video_encoding: Vec<VideoEncodeAcceleratorCapability<'a>>,
355}
356
357impl<'a> GPUInfoBuilder<'a> {
358 pub fn aux_attributes(mut self, aux_attributes: serde_json::Map<String, JsonValue>) -> Self { self.aux_attributes = Some(aux_attributes); self }
360 pub fn feature_status(mut self, feature_status: serde_json::Map<String, JsonValue>) -> Self { self.feature_status = Some(feature_status); self }
362 pub fn build(self) -> GPUInfo<'a> {
363 GPUInfo {
364 devices: self.devices,
365 aux_attributes: self.aux_attributes,
366 feature_status: self.feature_status,
367 driver_bug_workarounds: self.driver_bug_workarounds,
368 video_decoding: self.video_decoding,
369 video_encoding: self.video_encoding,
370 }
371 }
372}
373
374#[derive(Debug, Clone, Serialize, Deserialize, Default)]
377#[serde(rename_all = "camelCase")]
378pub struct ProcessInfo<'a> {
379 #[serde(rename = "type")]
381 type_: Cow<'a, str>,
382 id: u64,
384 #[serde(rename = "cpuTime")]
387 cpu_time: f64,
388}
389
390impl<'a> ProcessInfo<'a> {
391 pub fn builder(type_: impl Into<Cow<'a, str>>, id: u64, cpu_time: f64) -> ProcessInfoBuilder<'a> {
396 ProcessInfoBuilder {
397 type_: type_.into(),
398 id: id,
399 cpu_time: cpu_time,
400 }
401 }
402 pub fn type_(&self) -> &str { self.type_.as_ref() }
404 pub fn id(&self) -> u64 { self.id }
406 pub fn cpu_time(&self) -> f64 { self.cpu_time }
409}
410
411
412pub struct ProcessInfoBuilder<'a> {
413 type_: Cow<'a, str>,
414 id: u64,
415 cpu_time: f64,
416}
417
418impl<'a> ProcessInfoBuilder<'a> {
419 pub fn build(self) -> ProcessInfo<'a> {
420 ProcessInfo {
421 type_: self.type_,
422 id: self.id,
423 cpu_time: self.cpu_time,
424 }
425 }
426}
427
428#[derive(Debug, Clone, Serialize, Deserialize, Default)]
431#[serde(rename_all = "camelCase")]
432pub struct GetInfoReturns<'a> {
433 gpu: GPUInfo<'a>,
435 #[serde(rename = "modelName")]
438 model_name: Cow<'a, str>,
439 #[serde(rename = "modelVersion")]
442 model_version: Cow<'a, str>,
443 #[serde(rename = "commandLine")]
446 command_line: Cow<'a, str>,
447}
448
449impl<'a> GetInfoReturns<'a> {
450 pub fn builder(gpu: GPUInfo<'a>, model_name: impl Into<Cow<'a, str>>, model_version: impl Into<Cow<'a, str>>, command_line: impl Into<Cow<'a, str>>) -> GetInfoReturnsBuilder<'a> {
456 GetInfoReturnsBuilder {
457 gpu: gpu,
458 model_name: model_name.into(),
459 model_version: model_version.into(),
460 command_line: command_line.into(),
461 }
462 }
463 pub fn gpu(&self) -> &GPUInfo<'a> { &self.gpu }
465 pub fn model_name(&self) -> &str { self.model_name.as_ref() }
468 pub fn model_version(&self) -> &str { self.model_version.as_ref() }
471 pub fn command_line(&self) -> &str { self.command_line.as_ref() }
474}
475
476
477pub struct GetInfoReturnsBuilder<'a> {
478 gpu: GPUInfo<'a>,
479 model_name: Cow<'a, str>,
480 model_version: Cow<'a, str>,
481 command_line: Cow<'a, str>,
482}
483
484impl<'a> GetInfoReturnsBuilder<'a> {
485 pub fn build(self) -> GetInfoReturns<'a> {
486 GetInfoReturns {
487 gpu: self.gpu,
488 model_name: self.model_name,
489 model_version: self.model_version,
490 command_line: self.command_line,
491 }
492 }
493}
494
495#[derive(Debug, Clone, Serialize, Deserialize, Default)]
496pub struct GetInfoParams {}
497
498impl GetInfoParams { pub const METHOD: &'static str = "SystemInfo.getInfo"; }
499
500impl<'a> crate::CdpCommand<'a> for GetInfoParams {
501 const METHOD: &'static str = "SystemInfo.getInfo";
502 type Response = GetInfoReturns<'a>;
503}
504
505#[derive(Debug, Clone, Serialize, Deserialize, Default)]
508#[serde(rename_all = "camelCase")]
509pub struct GetFeatureStateParams<'a> {
510 #[serde(rename = "featureState")]
511 feature_state: Cow<'a, str>,
512}
513
514impl<'a> GetFeatureStateParams<'a> {
515 pub fn builder(feature_state: impl Into<Cow<'a, str>>) -> GetFeatureStateParamsBuilder<'a> {
518 GetFeatureStateParamsBuilder {
519 feature_state: feature_state.into(),
520 }
521 }
522 pub fn feature_state(&self) -> &str { self.feature_state.as_ref() }
523}
524
525
526pub struct GetFeatureStateParamsBuilder<'a> {
527 feature_state: Cow<'a, str>,
528}
529
530impl<'a> GetFeatureStateParamsBuilder<'a> {
531 pub fn build(self) -> GetFeatureStateParams<'a> {
532 GetFeatureStateParams {
533 feature_state: self.feature_state,
534 }
535 }
536}
537
538#[derive(Debug, Clone, Serialize, Deserialize, Default)]
541#[serde(rename_all = "camelCase")]
542pub struct GetFeatureStateReturns {
543 #[serde(rename = "featureEnabled")]
544 feature_enabled: bool,
545}
546
547impl GetFeatureStateReturns {
548 pub fn builder(feature_enabled: bool) -> GetFeatureStateReturnsBuilder {
551 GetFeatureStateReturnsBuilder {
552 feature_enabled: feature_enabled,
553 }
554 }
555 pub fn feature_enabled(&self) -> bool { self.feature_enabled }
556}
557
558
559pub struct GetFeatureStateReturnsBuilder {
560 feature_enabled: bool,
561}
562
563impl GetFeatureStateReturnsBuilder {
564 pub fn build(self) -> GetFeatureStateReturns {
565 GetFeatureStateReturns {
566 feature_enabled: self.feature_enabled,
567 }
568 }
569}
570
571impl<'a> GetFeatureStateParams<'a> { pub const METHOD: &'static str = "SystemInfo.getFeatureState"; }
572
573impl<'a> crate::CdpCommand<'a> for GetFeatureStateParams<'a> {
574 const METHOD: &'static str = "SystemInfo.getFeatureState";
575 type Response = GetFeatureStateReturns;
576}
577
578#[derive(Debug, Clone, Serialize, Deserialize, Default)]
581#[serde(rename_all = "camelCase")]
582pub struct GetProcessInfoReturns<'a> {
583 #[serde(rename = "processInfo")]
585 process_info: Vec<ProcessInfo<'a>>,
586}
587
588impl<'a> GetProcessInfoReturns<'a> {
589 pub fn builder(process_info: Vec<ProcessInfo<'a>>) -> GetProcessInfoReturnsBuilder<'a> {
592 GetProcessInfoReturnsBuilder {
593 process_info: process_info,
594 }
595 }
596 pub fn process_info(&self) -> &[ProcessInfo<'a>] { &self.process_info }
598}
599
600
601pub struct GetProcessInfoReturnsBuilder<'a> {
602 process_info: Vec<ProcessInfo<'a>>,
603}
604
605impl<'a> GetProcessInfoReturnsBuilder<'a> {
606 pub fn build(self) -> GetProcessInfoReturns<'a> {
607 GetProcessInfoReturns {
608 process_info: self.process_info,
609 }
610 }
611}
612
613#[derive(Debug, Clone, Serialize, Deserialize, Default)]
614pub struct GetProcessInfoParams {}
615
616impl GetProcessInfoParams { pub const METHOD: &'static str = "SystemInfo.getProcessInfo"; }
617
618impl<'a> crate::CdpCommand<'a> for GetProcessInfoParams {
619 const METHOD: &'static str = "SystemInfo.getProcessInfo";
620 type Response = GetProcessInfoReturns<'a>;
621}