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 vendorId: f64,
15 deviceId: f64,
17 #[serde(skip_serializing_if = "Option::is_none")]
19 subSysId: Option<f64>,
20 #[serde(skip_serializing_if = "Option::is_none")]
22 revision: Option<f64>,
23 vendorString: Cow<'a, str>,
25 deviceString: Cow<'a, str>,
27 driverVendor: Cow<'a, str>,
29 driverVersion: Cow<'a, str>,
31}
32
33impl<'a> GPUDevice<'a> {
34 pub fn builder(vendorId: f64, deviceId: f64, vendorString: impl Into<Cow<'a, str>>, deviceString: impl Into<Cow<'a, str>>, driverVendor: impl Into<Cow<'a, str>>, driverVersion: impl Into<Cow<'a, str>>) -> GPUDeviceBuilder<'a> {
35 GPUDeviceBuilder {
36 vendorId: vendorId,
37 deviceId: deviceId,
38 subSysId: None,
39 revision: None,
40 vendorString: vendorString.into(),
41 deviceString: deviceString.into(),
42 driverVendor: driverVendor.into(),
43 driverVersion: driverVersion.into(),
44 }
45 }
46 pub fn vendorId(&self) -> f64 { self.vendorId }
47 pub fn deviceId(&self) -> f64 { self.deviceId }
48 pub fn subSysId(&self) -> Option<f64> { self.subSysId }
49 pub fn revision(&self) -> Option<f64> { self.revision }
50 pub fn vendorString(&self) -> &str { self.vendorString.as_ref() }
51 pub fn deviceString(&self) -> &str { self.deviceString.as_ref() }
52 pub fn driverVendor(&self) -> &str { self.driverVendor.as_ref() }
53 pub fn driverVersion(&self) -> &str { self.driverVersion.as_ref() }
54}
55
56
57pub struct GPUDeviceBuilder<'a> {
58 vendorId: f64,
59 deviceId: f64,
60 subSysId: Option<f64>,
61 revision: Option<f64>,
62 vendorString: Cow<'a, str>,
63 deviceString: Cow<'a, str>,
64 driverVendor: Cow<'a, str>,
65 driverVersion: Cow<'a, str>,
66}
67
68impl<'a> GPUDeviceBuilder<'a> {
69 pub fn subSysId(mut self, subSysId: f64) -> Self { self.subSysId = Some(subSysId); self }
71 pub fn revision(mut self, revision: f64) -> Self { self.revision = Some(revision); self }
73 pub fn build(self) -> GPUDevice<'a> {
74 GPUDevice {
75 vendorId: self.vendorId,
76 deviceId: self.deviceId,
77 subSysId: self.subSysId,
78 revision: self.revision,
79 vendorString: self.vendorString,
80 deviceString: self.deviceString,
81 driverVendor: self.driverVendor,
82 driverVersion: self.driverVersion,
83 }
84 }
85}
86
87#[derive(Debug, Clone, Serialize, Deserialize, Default)]
90#[serde(rename_all = "camelCase")]
91pub struct Size {
92 width: u64,
94 height: i64,
96}
97
98impl Size {
99 pub fn builder(width: u64, height: i64) -> SizeBuilder {
100 SizeBuilder {
101 width: width,
102 height: height,
103 }
104 }
105 pub fn width(&self) -> u64 { self.width }
106 pub fn height(&self) -> i64 { self.height }
107}
108
109
110pub struct SizeBuilder {
111 width: u64,
112 height: i64,
113}
114
115impl SizeBuilder {
116 pub fn build(self) -> Size {
117 Size {
118 width: self.width,
119 height: self.height,
120 }
121 }
122}
123
124#[derive(Debug, Clone, Serialize, Deserialize, Default)]
128#[serde(rename_all = "camelCase")]
129pub struct VideoDecodeAcceleratorCapability<'a> {
130 profile: Cow<'a, str>,
132 maxResolution: Size,
134 minResolution: Size,
136}
137
138impl<'a> VideoDecodeAcceleratorCapability<'a> {
139 pub fn builder(profile: impl Into<Cow<'a, str>>, maxResolution: Size, minResolution: Size) -> VideoDecodeAcceleratorCapabilityBuilder<'a> {
140 VideoDecodeAcceleratorCapabilityBuilder {
141 profile: profile.into(),
142 maxResolution: maxResolution,
143 minResolution: minResolution,
144 }
145 }
146 pub fn profile(&self) -> &str { self.profile.as_ref() }
147 pub fn maxResolution(&self) -> &Size { &self.maxResolution }
148 pub fn minResolution(&self) -> &Size { &self.minResolution }
149}
150
151
152pub struct VideoDecodeAcceleratorCapabilityBuilder<'a> {
153 profile: Cow<'a, str>,
154 maxResolution: Size,
155 minResolution: Size,
156}
157
158impl<'a> VideoDecodeAcceleratorCapabilityBuilder<'a> {
159 pub fn build(self) -> VideoDecodeAcceleratorCapability<'a> {
160 VideoDecodeAcceleratorCapability {
161 profile: self.profile,
162 maxResolution: self.maxResolution,
163 minResolution: self.minResolution,
164 }
165 }
166}
167
168#[derive(Debug, Clone, Serialize, Deserialize, Default)]
172#[serde(rename_all = "camelCase")]
173pub struct VideoEncodeAcceleratorCapability<'a> {
174 profile: Cow<'a, str>,
176 maxResolution: Size,
178 maxFramerateNumerator: i64,
182 maxFramerateDenominator: i64,
183}
184
185impl<'a> VideoEncodeAcceleratorCapability<'a> {
186 pub fn builder(profile: impl Into<Cow<'a, str>>, maxResolution: Size, maxFramerateNumerator: i64, maxFramerateDenominator: i64) -> VideoEncodeAcceleratorCapabilityBuilder<'a> {
187 VideoEncodeAcceleratorCapabilityBuilder {
188 profile: profile.into(),
189 maxResolution: maxResolution,
190 maxFramerateNumerator: maxFramerateNumerator,
191 maxFramerateDenominator: maxFramerateDenominator,
192 }
193 }
194 pub fn profile(&self) -> &str { self.profile.as_ref() }
195 pub fn maxResolution(&self) -> &Size { &self.maxResolution }
196 pub fn maxFramerateNumerator(&self) -> i64 { self.maxFramerateNumerator }
197 pub fn maxFramerateDenominator(&self) -> i64 { self.maxFramerateDenominator }
198}
199
200
201pub struct VideoEncodeAcceleratorCapabilityBuilder<'a> {
202 profile: Cow<'a, str>,
203 maxResolution: Size,
204 maxFramerateNumerator: i64,
205 maxFramerateDenominator: i64,
206}
207
208impl<'a> VideoEncodeAcceleratorCapabilityBuilder<'a> {
209 pub fn build(self) -> VideoEncodeAcceleratorCapability<'a> {
210 VideoEncodeAcceleratorCapability {
211 profile: self.profile,
212 maxResolution: self.maxResolution,
213 maxFramerateNumerator: self.maxFramerateNumerator,
214 maxFramerateDenominator: self.maxFramerateDenominator,
215 }
216 }
217}
218
219#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
222pub enum SubsamplingFormat {
223 #[default]
224 #[serde(rename = "yuv420")]
225 Yuv420,
226 #[serde(rename = "yuv422")]
227 Yuv422,
228 #[serde(rename = "yuv444")]
229 Yuv444,
230}
231
232#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
235pub enum ImageType {
236 #[default]
237 #[serde(rename = "jpeg")]
238 Jpeg,
239 #[serde(rename = "webp")]
240 Webp,
241 #[serde(rename = "unknown")]
242 Unknown,
243}
244
245#[derive(Debug, Clone, Serialize, Deserialize, Default)]
248#[serde(rename_all = "camelCase")]
249pub struct GPUInfo<'a> {
250 devices: Vec<GPUDevice<'a>>,
252 #[serde(skip_serializing_if = "Option::is_none")]
254 auxAttributes: Option<serde_json::Map<String, JsonValue>>,
255 #[serde(skip_serializing_if = "Option::is_none")]
257 featureStatus: Option<serde_json::Map<String, JsonValue>>,
258 driverBugWorkarounds: Vec<Cow<'a, str>>,
260 videoDecoding: Vec<VideoDecodeAcceleratorCapability<'a>>,
262 videoEncoding: Vec<VideoEncodeAcceleratorCapability<'a>>,
264}
265
266impl<'a> GPUInfo<'a> {
267 pub fn builder(devices: Vec<GPUDevice<'a>>, driverBugWorkarounds: Vec<Cow<'a, str>>, videoDecoding: Vec<VideoDecodeAcceleratorCapability<'a>>, videoEncoding: Vec<VideoEncodeAcceleratorCapability<'a>>) -> GPUInfoBuilder<'a> {
268 GPUInfoBuilder {
269 devices: devices,
270 auxAttributes: None,
271 featureStatus: None,
272 driverBugWorkarounds: driverBugWorkarounds,
273 videoDecoding: videoDecoding,
274 videoEncoding: videoEncoding,
275 }
276 }
277 pub fn devices(&self) -> &[GPUDevice<'a>] { &self.devices }
278 pub fn auxAttributes(&self) -> Option<&serde_json::Map<String, JsonValue>> { self.auxAttributes.as_ref() }
279 pub fn featureStatus(&self) -> Option<&serde_json::Map<String, JsonValue>> { self.featureStatus.as_ref() }
280 pub fn driverBugWorkarounds(&self) -> &[Cow<'a, str>] { &self.driverBugWorkarounds }
281 pub fn videoDecoding(&self) -> &[VideoDecodeAcceleratorCapability<'a>] { &self.videoDecoding }
282 pub fn videoEncoding(&self) -> &[VideoEncodeAcceleratorCapability<'a>] { &self.videoEncoding }
283}
284
285
286pub struct GPUInfoBuilder<'a> {
287 devices: Vec<GPUDevice<'a>>,
288 auxAttributes: Option<serde_json::Map<String, JsonValue>>,
289 featureStatus: Option<serde_json::Map<String, JsonValue>>,
290 driverBugWorkarounds: Vec<Cow<'a, str>>,
291 videoDecoding: Vec<VideoDecodeAcceleratorCapability<'a>>,
292 videoEncoding: Vec<VideoEncodeAcceleratorCapability<'a>>,
293}
294
295impl<'a> GPUInfoBuilder<'a> {
296 pub fn auxAttributes(mut self, auxAttributes: serde_json::Map<String, JsonValue>) -> Self { self.auxAttributes = Some(auxAttributes); self }
298 pub fn featureStatus(mut self, featureStatus: serde_json::Map<String, JsonValue>) -> Self { self.featureStatus = Some(featureStatus); self }
300 pub fn build(self) -> GPUInfo<'a> {
301 GPUInfo {
302 devices: self.devices,
303 auxAttributes: self.auxAttributes,
304 featureStatus: self.featureStatus,
305 driverBugWorkarounds: self.driverBugWorkarounds,
306 videoDecoding: self.videoDecoding,
307 videoEncoding: self.videoEncoding,
308 }
309 }
310}
311
312#[derive(Debug, Clone, Serialize, Deserialize, Default)]
315#[serde(rename_all = "camelCase")]
316pub struct ProcessInfo<'a> {
317 #[serde(rename = "type")]
319 type_: Cow<'a, str>,
320 id: u64,
322 cpuTime: f64,
325}
326
327impl<'a> ProcessInfo<'a> {
328 pub fn builder(type_: impl Into<Cow<'a, str>>, id: u64, cpuTime: f64) -> ProcessInfoBuilder<'a> {
329 ProcessInfoBuilder {
330 type_: type_.into(),
331 id: id,
332 cpuTime: cpuTime,
333 }
334 }
335 pub fn type_(&self) -> &str { self.type_.as_ref() }
336 pub fn id(&self) -> u64 { self.id }
337 pub fn cpuTime(&self) -> f64 { self.cpuTime }
338}
339
340
341pub struct ProcessInfoBuilder<'a> {
342 type_: Cow<'a, str>,
343 id: u64,
344 cpuTime: f64,
345}
346
347impl<'a> ProcessInfoBuilder<'a> {
348 pub fn build(self) -> ProcessInfo<'a> {
349 ProcessInfo {
350 type_: self.type_,
351 id: self.id,
352 cpuTime: self.cpuTime,
353 }
354 }
355}
356
357#[derive(Debug, Clone, Serialize, Deserialize, Default)]
360#[serde(rename_all = "camelCase")]
361pub struct GetInfoReturns<'a> {
362 gpu: GPUInfo<'a>,
364 modelName: Cow<'a, str>,
367 modelVersion: Cow<'a, str>,
370 commandLine: Cow<'a, str>,
373}
374
375impl<'a> GetInfoReturns<'a> {
376 pub fn builder(gpu: GPUInfo<'a>, modelName: impl Into<Cow<'a, str>>, modelVersion: impl Into<Cow<'a, str>>, commandLine: impl Into<Cow<'a, str>>) -> GetInfoReturnsBuilder<'a> {
377 GetInfoReturnsBuilder {
378 gpu: gpu,
379 modelName: modelName.into(),
380 modelVersion: modelVersion.into(),
381 commandLine: commandLine.into(),
382 }
383 }
384 pub fn gpu(&self) -> &GPUInfo<'a> { &self.gpu }
385 pub fn modelName(&self) -> &str { self.modelName.as_ref() }
386 pub fn modelVersion(&self) -> &str { self.modelVersion.as_ref() }
387 pub fn commandLine(&self) -> &str { self.commandLine.as_ref() }
388}
389
390
391pub struct GetInfoReturnsBuilder<'a> {
392 gpu: GPUInfo<'a>,
393 modelName: Cow<'a, str>,
394 modelVersion: Cow<'a, str>,
395 commandLine: Cow<'a, str>,
396}
397
398impl<'a> GetInfoReturnsBuilder<'a> {
399 pub fn build(self) -> GetInfoReturns<'a> {
400 GetInfoReturns {
401 gpu: self.gpu,
402 modelName: self.modelName,
403 modelVersion: self.modelVersion,
404 commandLine: self.commandLine,
405 }
406 }
407}
408
409#[derive(Debug, Clone, Serialize, Deserialize, Default)]
410pub struct GetInfoParams {}
411
412impl GetInfoParams { pub const METHOD: &'static str = "SystemInfo.getInfo"; }
413
414impl<'a> crate::CdpCommand<'a> for GetInfoParams {
415 const METHOD: &'static str = "SystemInfo.getInfo";
416 type Response = GetInfoReturns<'a>;
417}
418
419#[derive(Debug, Clone, Serialize, Deserialize, Default)]
422#[serde(rename_all = "camelCase")]
423pub struct GetFeatureStateParams<'a> {
424 featureState: Cow<'a, str>,
425}
426
427impl<'a> GetFeatureStateParams<'a> {
428 pub fn builder(featureState: impl Into<Cow<'a, str>>) -> GetFeatureStateParamsBuilder<'a> {
429 GetFeatureStateParamsBuilder {
430 featureState: featureState.into(),
431 }
432 }
433 pub fn featureState(&self) -> &str { self.featureState.as_ref() }
434}
435
436
437pub struct GetFeatureStateParamsBuilder<'a> {
438 featureState: Cow<'a, str>,
439}
440
441impl<'a> GetFeatureStateParamsBuilder<'a> {
442 pub fn build(self) -> GetFeatureStateParams<'a> {
443 GetFeatureStateParams {
444 featureState: self.featureState,
445 }
446 }
447}
448
449#[derive(Debug, Clone, Serialize, Deserialize, Default)]
452#[serde(rename_all = "camelCase")]
453pub struct GetFeatureStateReturns {
454 featureEnabled: bool,
455}
456
457impl GetFeatureStateReturns {
458 pub fn builder(featureEnabled: bool) -> GetFeatureStateReturnsBuilder {
459 GetFeatureStateReturnsBuilder {
460 featureEnabled: featureEnabled,
461 }
462 }
463 pub fn featureEnabled(&self) -> bool { self.featureEnabled }
464}
465
466
467pub struct GetFeatureStateReturnsBuilder {
468 featureEnabled: bool,
469}
470
471impl GetFeatureStateReturnsBuilder {
472 pub fn build(self) -> GetFeatureStateReturns {
473 GetFeatureStateReturns {
474 featureEnabled: self.featureEnabled,
475 }
476 }
477}
478
479impl<'a> GetFeatureStateParams<'a> { pub const METHOD: &'static str = "SystemInfo.getFeatureState"; }
480
481impl<'a> crate::CdpCommand<'a> for GetFeatureStateParams<'a> {
482 const METHOD: &'static str = "SystemInfo.getFeatureState";
483 type Response = GetFeatureStateReturns;
484}
485
486#[derive(Debug, Clone, Serialize, Deserialize, Default)]
489#[serde(rename_all = "camelCase")]
490pub struct GetProcessInfoReturns<'a> {
491 processInfo: Vec<ProcessInfo<'a>>,
493}
494
495impl<'a> GetProcessInfoReturns<'a> {
496 pub fn builder(processInfo: Vec<ProcessInfo<'a>>) -> GetProcessInfoReturnsBuilder<'a> {
497 GetProcessInfoReturnsBuilder {
498 processInfo: processInfo,
499 }
500 }
501 pub fn processInfo(&self) -> &[ProcessInfo<'a>] { &self.processInfo }
502}
503
504
505pub struct GetProcessInfoReturnsBuilder<'a> {
506 processInfo: Vec<ProcessInfo<'a>>,
507}
508
509impl<'a> GetProcessInfoReturnsBuilder<'a> {
510 pub fn build(self) -> GetProcessInfoReturns<'a> {
511 GetProcessInfoReturns {
512 processInfo: self.processInfo,
513 }
514 }
515}
516
517#[derive(Debug, Clone, Serialize, Deserialize, Default)]
518pub struct GetProcessInfoParams {}
519
520impl GetProcessInfoParams { pub const METHOD: &'static str = "SystemInfo.getProcessInfo"; }
521
522impl<'a> crate::CdpCommand<'a> for GetProcessInfoParams {
523 const METHOD: &'static str = "SystemInfo.getProcessInfo";
524 type Response = GetProcessInfoReturns<'a>;
525}