use serde::{Serialize, Deserialize};
use serde_json::Value as JsonValue;
use std::borrow::Cow;
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GPUDevice<'a> {
#[serde(rename = "vendorId")]
vendor_id: f64,
#[serde(rename = "deviceId")]
device_id: f64,
#[serde(skip_serializing_if = "Option::is_none", rename = "subSysId")]
sub_sys_id: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
revision: Option<f64>,
#[serde(rename = "vendorString")]
vendor_string: Cow<'a, str>,
#[serde(rename = "deviceString")]
device_string: Cow<'a, str>,
#[serde(rename = "driverVendor")]
driver_vendor: Cow<'a, str>,
#[serde(rename = "driverVersion")]
driver_version: Cow<'a, str>,
}
impl<'a> GPUDevice<'a> {
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> {
GPUDeviceBuilder {
vendor_id: vendor_id,
device_id: device_id,
sub_sys_id: None,
revision: None,
vendor_string: vendor_string.into(),
device_string: device_string.into(),
driver_vendor: driver_vendor.into(),
driver_version: driver_version.into(),
}
}
pub fn vendor_id(&self) -> f64 { self.vendor_id }
pub fn device_id(&self) -> f64 { self.device_id }
pub fn sub_sys_id(&self) -> Option<f64> { self.sub_sys_id }
pub fn revision(&self) -> Option<f64> { self.revision }
pub fn vendor_string(&self) -> &str { self.vendor_string.as_ref() }
pub fn device_string(&self) -> &str { self.device_string.as_ref() }
pub fn driver_vendor(&self) -> &str { self.driver_vendor.as_ref() }
pub fn driver_version(&self) -> &str { self.driver_version.as_ref() }
}
pub struct GPUDeviceBuilder<'a> {
vendor_id: f64,
device_id: f64,
sub_sys_id: Option<f64>,
revision: Option<f64>,
vendor_string: Cow<'a, str>,
device_string: Cow<'a, str>,
driver_vendor: Cow<'a, str>,
driver_version: Cow<'a, str>,
}
impl<'a> GPUDeviceBuilder<'a> {
pub fn sub_sys_id(mut self, sub_sys_id: f64) -> Self { self.sub_sys_id = Some(sub_sys_id); self }
pub fn revision(mut self, revision: f64) -> Self { self.revision = Some(revision); self }
pub fn build(self) -> GPUDevice<'a> {
GPUDevice {
vendor_id: self.vendor_id,
device_id: self.device_id,
sub_sys_id: self.sub_sys_id,
revision: self.revision,
vendor_string: self.vendor_string,
device_string: self.device_string,
driver_vendor: self.driver_vendor,
driver_version: self.driver_version,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct Size {
width: u64,
height: i64,
}
impl Size {
pub fn builder(width: u64, height: i64) -> SizeBuilder {
SizeBuilder {
width: width,
height: height,
}
}
pub fn width(&self) -> u64 { self.width }
pub fn height(&self) -> i64 { self.height }
}
pub struct SizeBuilder {
width: u64,
height: i64,
}
impl SizeBuilder {
pub fn build(self) -> Size {
Size {
width: self.width,
height: self.height,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct VideoDecodeAcceleratorCapability<'a> {
profile: Cow<'a, str>,
#[serde(rename = "maxResolution")]
max_resolution: Size,
#[serde(rename = "minResolution")]
min_resolution: Size,
}
impl<'a> VideoDecodeAcceleratorCapability<'a> {
pub fn builder(profile: impl Into<Cow<'a, str>>, max_resolution: Size, min_resolution: Size) -> VideoDecodeAcceleratorCapabilityBuilder<'a> {
VideoDecodeAcceleratorCapabilityBuilder {
profile: profile.into(),
max_resolution: max_resolution,
min_resolution: min_resolution,
}
}
pub fn profile(&self) -> &str { self.profile.as_ref() }
pub fn max_resolution(&self) -> &Size { &self.max_resolution }
pub fn min_resolution(&self) -> &Size { &self.min_resolution }
}
pub struct VideoDecodeAcceleratorCapabilityBuilder<'a> {
profile: Cow<'a, str>,
max_resolution: Size,
min_resolution: Size,
}
impl<'a> VideoDecodeAcceleratorCapabilityBuilder<'a> {
pub fn build(self) -> VideoDecodeAcceleratorCapability<'a> {
VideoDecodeAcceleratorCapability {
profile: self.profile,
max_resolution: self.max_resolution,
min_resolution: self.min_resolution,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct VideoEncodeAcceleratorCapability<'a> {
profile: Cow<'a, str>,
#[serde(rename = "maxResolution")]
max_resolution: Size,
#[serde(rename = "maxFramerateNumerator")]
max_framerate_numerator: i64,
#[serde(rename = "maxFramerateDenominator")]
max_framerate_denominator: i64,
}
impl<'a> VideoEncodeAcceleratorCapability<'a> {
pub fn builder(profile: impl Into<Cow<'a, str>>, max_resolution: Size, max_framerate_numerator: i64, max_framerate_denominator: i64) -> VideoEncodeAcceleratorCapabilityBuilder<'a> {
VideoEncodeAcceleratorCapabilityBuilder {
profile: profile.into(),
max_resolution: max_resolution,
max_framerate_numerator: max_framerate_numerator,
max_framerate_denominator: max_framerate_denominator,
}
}
pub fn profile(&self) -> &str { self.profile.as_ref() }
pub fn max_resolution(&self) -> &Size { &self.max_resolution }
pub fn max_framerate_numerator(&self) -> i64 { self.max_framerate_numerator }
pub fn max_framerate_denominator(&self) -> i64 { self.max_framerate_denominator }
}
pub struct VideoEncodeAcceleratorCapabilityBuilder<'a> {
profile: Cow<'a, str>,
max_resolution: Size,
max_framerate_numerator: i64,
max_framerate_denominator: i64,
}
impl<'a> VideoEncodeAcceleratorCapabilityBuilder<'a> {
pub fn build(self) -> VideoEncodeAcceleratorCapability<'a> {
VideoEncodeAcceleratorCapability {
profile: self.profile,
max_resolution: self.max_resolution,
max_framerate_numerator: self.max_framerate_numerator,
max_framerate_denominator: self.max_framerate_denominator,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum SubsamplingFormat {
#[default]
#[serde(rename = "yuv420")]
Yuv420,
#[serde(rename = "yuv422")]
Yuv422,
#[serde(rename = "yuv444")]
Yuv444,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum ImageType {
#[default]
#[serde(rename = "jpeg")]
Jpeg,
#[serde(rename = "webp")]
Webp,
#[serde(rename = "unknown")]
Unknown,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GPUInfo<'a> {
devices: Vec<GPUDevice<'a>>,
#[serde(skip_serializing_if = "Option::is_none", rename = "auxAttributes")]
aux_attributes: Option<serde_json::Map<String, JsonValue>>,
#[serde(skip_serializing_if = "Option::is_none", rename = "featureStatus")]
feature_status: Option<serde_json::Map<String, JsonValue>>,
#[serde(rename = "driverBugWorkarounds")]
driver_bug_workarounds: Vec<Cow<'a, str>>,
#[serde(rename = "videoDecoding")]
video_decoding: Vec<VideoDecodeAcceleratorCapability<'a>>,
#[serde(rename = "videoEncoding")]
video_encoding: Vec<VideoEncodeAcceleratorCapability<'a>>,
}
impl<'a> GPUInfo<'a> {
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> {
GPUInfoBuilder {
devices: devices,
aux_attributes: None,
feature_status: None,
driver_bug_workarounds: driver_bug_workarounds,
video_decoding: video_decoding,
video_encoding: video_encoding,
}
}
pub fn devices(&self) -> &[GPUDevice<'a>] { &self.devices }
pub fn aux_attributes(&self) -> Option<&serde_json::Map<String, JsonValue>> { self.aux_attributes.as_ref() }
pub fn feature_status(&self) -> Option<&serde_json::Map<String, JsonValue>> { self.feature_status.as_ref() }
pub fn driver_bug_workarounds(&self) -> &[Cow<'a, str>] { &self.driver_bug_workarounds }
pub fn video_decoding(&self) -> &[VideoDecodeAcceleratorCapability<'a>] { &self.video_decoding }
pub fn video_encoding(&self) -> &[VideoEncodeAcceleratorCapability<'a>] { &self.video_encoding }
}
pub struct GPUInfoBuilder<'a> {
devices: Vec<GPUDevice<'a>>,
aux_attributes: Option<serde_json::Map<String, JsonValue>>,
feature_status: Option<serde_json::Map<String, JsonValue>>,
driver_bug_workarounds: Vec<Cow<'a, str>>,
video_decoding: Vec<VideoDecodeAcceleratorCapability<'a>>,
video_encoding: Vec<VideoEncodeAcceleratorCapability<'a>>,
}
impl<'a> GPUInfoBuilder<'a> {
pub fn aux_attributes(mut self, aux_attributes: serde_json::Map<String, JsonValue>) -> Self { self.aux_attributes = Some(aux_attributes); self }
pub fn feature_status(mut self, feature_status: serde_json::Map<String, JsonValue>) -> Self { self.feature_status = Some(feature_status); self }
pub fn build(self) -> GPUInfo<'a> {
GPUInfo {
devices: self.devices,
aux_attributes: self.aux_attributes,
feature_status: self.feature_status,
driver_bug_workarounds: self.driver_bug_workarounds,
video_decoding: self.video_decoding,
video_encoding: self.video_encoding,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ProcessInfo<'a> {
#[serde(rename = "type")]
type_: Cow<'a, str>,
id: u64,
#[serde(rename = "cpuTime")]
cpu_time: f64,
}
impl<'a> ProcessInfo<'a> {
pub fn builder(type_: impl Into<Cow<'a, str>>, id: u64, cpu_time: f64) -> ProcessInfoBuilder<'a> {
ProcessInfoBuilder {
type_: type_.into(),
id: id,
cpu_time: cpu_time,
}
}
pub fn type_(&self) -> &str { self.type_.as_ref() }
pub fn id(&self) -> u64 { self.id }
pub fn cpu_time(&self) -> f64 { self.cpu_time }
}
pub struct ProcessInfoBuilder<'a> {
type_: Cow<'a, str>,
id: u64,
cpu_time: f64,
}
impl<'a> ProcessInfoBuilder<'a> {
pub fn build(self) -> ProcessInfo<'a> {
ProcessInfo {
type_: self.type_,
id: self.id,
cpu_time: self.cpu_time,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetInfoReturns<'a> {
gpu: GPUInfo<'a>,
#[serde(rename = "modelName")]
model_name: Cow<'a, str>,
#[serde(rename = "modelVersion")]
model_version: Cow<'a, str>,
#[serde(rename = "commandLine")]
command_line: Cow<'a, str>,
}
impl<'a> GetInfoReturns<'a> {
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> {
GetInfoReturnsBuilder {
gpu: gpu,
model_name: model_name.into(),
model_version: model_version.into(),
command_line: command_line.into(),
}
}
pub fn gpu(&self) -> &GPUInfo<'a> { &self.gpu }
pub fn model_name(&self) -> &str { self.model_name.as_ref() }
pub fn model_version(&self) -> &str { self.model_version.as_ref() }
pub fn command_line(&self) -> &str { self.command_line.as_ref() }
}
pub struct GetInfoReturnsBuilder<'a> {
gpu: GPUInfo<'a>,
model_name: Cow<'a, str>,
model_version: Cow<'a, str>,
command_line: Cow<'a, str>,
}
impl<'a> GetInfoReturnsBuilder<'a> {
pub fn build(self) -> GetInfoReturns<'a> {
GetInfoReturns {
gpu: self.gpu,
model_name: self.model_name,
model_version: self.model_version,
command_line: self.command_line,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct GetInfoParams {}
impl GetInfoParams { pub const METHOD: &'static str = "SystemInfo.getInfo"; }
impl<'a> crate::CdpCommand<'a> for GetInfoParams {
const METHOD: &'static str = "SystemInfo.getInfo";
type Response = GetInfoReturns<'a>;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetFeatureStateParams<'a> {
#[serde(rename = "featureState")]
feature_state: Cow<'a, str>,
}
impl<'a> GetFeatureStateParams<'a> {
pub fn builder(feature_state: impl Into<Cow<'a, str>>) -> GetFeatureStateParamsBuilder<'a> {
GetFeatureStateParamsBuilder {
feature_state: feature_state.into(),
}
}
pub fn feature_state(&self) -> &str { self.feature_state.as_ref() }
}
pub struct GetFeatureStateParamsBuilder<'a> {
feature_state: Cow<'a, str>,
}
impl<'a> GetFeatureStateParamsBuilder<'a> {
pub fn build(self) -> GetFeatureStateParams<'a> {
GetFeatureStateParams {
feature_state: self.feature_state,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetFeatureStateReturns {
#[serde(rename = "featureEnabled")]
feature_enabled: bool,
}
impl GetFeatureStateReturns {
pub fn builder(feature_enabled: bool) -> GetFeatureStateReturnsBuilder {
GetFeatureStateReturnsBuilder {
feature_enabled: feature_enabled,
}
}
pub fn feature_enabled(&self) -> bool { self.feature_enabled }
}
pub struct GetFeatureStateReturnsBuilder {
feature_enabled: bool,
}
impl GetFeatureStateReturnsBuilder {
pub fn build(self) -> GetFeatureStateReturns {
GetFeatureStateReturns {
feature_enabled: self.feature_enabled,
}
}
}
impl<'a> GetFeatureStateParams<'a> { pub const METHOD: &'static str = "SystemInfo.getFeatureState"; }
impl<'a> crate::CdpCommand<'a> for GetFeatureStateParams<'a> {
const METHOD: &'static str = "SystemInfo.getFeatureState";
type Response = GetFeatureStateReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetProcessInfoReturns<'a> {
#[serde(rename = "processInfo")]
process_info: Vec<ProcessInfo<'a>>,
}
impl<'a> GetProcessInfoReturns<'a> {
pub fn builder(process_info: Vec<ProcessInfo<'a>>) -> GetProcessInfoReturnsBuilder<'a> {
GetProcessInfoReturnsBuilder {
process_info: process_info,
}
}
pub fn process_info(&self) -> &[ProcessInfo<'a>] { &self.process_info }
}
pub struct GetProcessInfoReturnsBuilder<'a> {
process_info: Vec<ProcessInfo<'a>>,
}
impl<'a> GetProcessInfoReturnsBuilder<'a> {
pub fn build(self) -> GetProcessInfoReturns<'a> {
GetProcessInfoReturns {
process_info: self.process_info,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct GetProcessInfoParams {}
impl GetProcessInfoParams { pub const METHOD: &'static str = "SystemInfo.getProcessInfo"; }
impl<'a> crate::CdpCommand<'a> for GetProcessInfoParams {
const METHOD: &'static str = "SystemInfo.getProcessInfo";
type Response = GetProcessInfoReturns<'a>;
}