Further improve the daemon controller pattern and reduce cloned code

This commit is contained in:
Luke D. Jones
2022-09-23 20:07:43 +12:00
parent 7ea1f41286
commit 30550aaa91
21 changed files with 382 additions and 416 deletions

View File

@@ -1,6 +1,5 @@
use crate::error::RogError;
use crate::GetSupported;
use async_trait::async_trait;
use log::{info, warn};
use rog_platform::platform::AsusPlatform;
use rog_platform::supported::PlatformProfileFunctions;
@@ -39,22 +38,6 @@ impl GetSupported for CtrlPlatformProfile {
}
}
#[async_trait]
impl crate::Reloadable for CtrlPlatformProfile {
/// Fetch the active profile and use that to set all related components up
async fn reload(&mut self) -> Result<(), RogError> {
if let Some(curves) = &mut self.config.fan_curves {
if let Ok(mut device) = FanCurveProfiles::get_device() {
// There is a possibility that the curve was default zeroed, so this call initialises
// the data from system read and we need to save it after
curves.write_profile_curve_to_platform(self.config.active_profile, &mut device)?;
self.config.write();
}
}
Ok(())
}
}
impl CtrlPlatformProfile {
pub fn new(config: ProfileConfig) -> Result<Self, RogError> {
let platform = AsusPlatform::new()?;