ridiculous refactor to allow enums to be dbus strings for better TS generation

This commit is contained in:
Luke D. Jones
2023-06-27 21:16:13 +12:00
parent fca7d23a31
commit 7b17a13ce7
43 changed files with 1516 additions and 267 deletions

View File

@@ -13,6 +13,7 @@ dbus = ["zbus"]
udev.workspace = true
serde.workspace = true
serde_derive.workspace = true
typeshare.workspace = true
zbus = { workspace = true, optional = true }

View File

@@ -1,4 +1,5 @@
use serde_derive::{Deserialize, Serialize};
use typeshare::typeshare;
use udev::Device;
#[cfg(feature = "dbus")]
use zbus::zvariant::Type;
@@ -26,6 +27,7 @@ pub(crate) fn temp_str(fan: char, index: usize) -> String {
buf
}
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type))]
#[derive(Deserialize, Serialize, Default, Debug, Clone)]
pub struct CurveData {
@@ -195,6 +197,7 @@ impl CurveData {
}
/// A `FanCurveSet` contains both CPU and GPU fan curve data
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type))]
#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct FanCurveSet {

View File

@@ -9,6 +9,7 @@ use std::path::Path;
use error::ProfileError;
use fan_curve_set::{CurveData, FanCurveSet};
use serde_derive::{Deserialize, Serialize};
use typeshare::typeshare;
use udev::Device;
#[cfg(feature = "dbus")]
use zbus::zvariant::Type;
@@ -35,7 +36,8 @@ pub fn find_fan_curve_node() -> Result<Option<Device>, ProfileError> {
Err(ProfileError::NotSupported)
}
#[cfg_attr(feature = "dbus", derive(Type))]
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type), zvariant(signature = "s"))]
#[derive(Deserialize, Serialize, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
pub enum Profile {
Balanced,
@@ -127,7 +129,8 @@ impl Display for Profile {
}
}
#[cfg_attr(feature = "dbus", derive(Type))]
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type), zvariant(signature = "s"))]
#[derive(Deserialize, Serialize, Debug, PartialEq, Eq, Clone, Copy)]
pub enum FanCurvePU {
CPU,
@@ -162,6 +165,7 @@ impl Default for FanCurvePU {
}
/// Main purpose of `FanCurves` is to enable restoring state on system boot
#[typeshare]
#[cfg_attr(feature = "dbus", derive(Type))]
#[derive(Deserialize, Serialize, Debug, Default)]
pub struct FanCurveProfiles {