Skip to content

Commit

Permalink
chore: avoid serializing null fields in device stats and info
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-zlobintsev committed Nov 16, 2024
1 parent 419814e commit 885e32d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lact-schema/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub fn default_fan_curve() -> FanCurveMap {
#[derive(Serialize, Deserialize, Debug)]
pub struct Pong;

#[skip_serializing_none]
#[derive(Serialize, Deserialize, Debug)]
pub struct SystemInfo {
pub version: String,
Expand All @@ -67,6 +68,7 @@ pub struct SystemInfo {
pub amdgpu_overdrive_enabled: Option<bool>,
}

#[skip_serializing_none]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct DeviceListEntry {
pub id: String,
Expand All @@ -88,6 +90,7 @@ pub struct GpuPciInfo {
pub subsystem_pci_info: PciInfo,
}

#[skip_serializing_none]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct DeviceInfo {
pub pci_info: Option<GpuPciInfo>,
Expand All @@ -98,6 +101,7 @@ pub struct DeviceInfo {
pub drm_info: Option<DrmInfo>,
}

#[skip_serializing_none]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct DrmInfo {
pub device_name: Option<String>,
Expand All @@ -118,6 +122,7 @@ pub struct DrmInfo {
pub memory_info: Option<DrmMemoryInfo>,
}

#[skip_serializing_none]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct DrmMemoryInfo {
pub cpu_accessible_used: u64,
Expand Down Expand Up @@ -169,6 +174,7 @@ impl From<AmdClocksTableGen> for ClocksInfo {
}
}

#[skip_serializing_none]
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct LinkInfo {
pub current_width: Option<String>,
Expand All @@ -187,6 +193,7 @@ pub struct VulkanInfo {
pub extensions: IndexMap<Cow<'static, str>, bool>,
}

#[skip_serializing_none]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct VulkanDriverInfo {
pub version: u32,
Expand All @@ -195,6 +202,7 @@ pub struct VulkanDriverInfo {
pub driver_version: Option<String>,
}

#[skip_serializing_none]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct PciInfo {
pub vendor_id: String,
Expand All @@ -203,6 +211,7 @@ pub struct PciInfo {
pub model: Option<String>,
}

#[skip_serializing_none]
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct DeviceStats {
pub fan: FanStats,
Expand All @@ -219,6 +228,7 @@ pub struct DeviceStats {
pub throttle_info: Option<BTreeMap<String, Vec<String>>>,
}

#[skip_serializing_none]
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct FanStats {
pub control_enabled: bool,
Expand Down Expand Up @@ -247,25 +257,29 @@ pub struct PmfwInfo {
pub zero_rpm_temperature: Option<FanInfo>,
}

#[skip_serializing_none]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, Default)]
pub struct ClockspeedStats {
pub gpu_clockspeed: Option<u64>,
pub current_gfxclk: Option<u16>,
pub vram_clockspeed: Option<u64>,
}

#[skip_serializing_none]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, Default)]
pub struct VoltageStats {
pub gpu: Option<u64>,
pub northbridge: Option<u64>,
}

#[skip_serializing_none]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, Default)]
pub struct VramStats {
pub total: Option<u64>,
pub used: Option<u64>,
}

#[skip_serializing_none]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, Default)]
pub struct PowerStats {
pub average: Option<f64>,
Expand All @@ -288,6 +302,7 @@ impl PowerStates {
}
}

#[skip_serializing_none]
#[derive(Serialize, Deserialize, Debug, Clone, Copy)]
pub struct PowerState {
pub enabled: bool,
Expand Down

0 comments on commit 885e32d

Please sign in to comment.