mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Split fan-curve config to own file
This commit is contained in:
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Better handling of non-existant config files
|
- Better handling of non-existant config files
|
||||||
- Move all config handling to generic traits for better consistency
|
- Move all config handling to generic traits for better consistency
|
||||||
- Re-parse all configs to RON format
|
- Re-parse all configs to RON format
|
||||||
|
- Move fan-curve config to own config file
|
||||||
- Added option to set `disable_nvidia_powerd_on_battery`
|
- Added option to set `disable_nvidia_powerd_on_battery`
|
||||||
- Add short log entry to throttle_thermal_policy change detection
|
- Add short log entry to throttle_thermal_policy change detection
|
||||||
- ROGCC: Don't notify user if changing to same mux mode
|
- ROGCC: Don't notify user if changing to same mux mode
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use serde_derive::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::config_traits::{StdConfig, StdConfigLoad3};
|
use crate::config_traits::{StdConfig, StdConfigLoad3};
|
||||||
|
|
||||||
pub static CONFIG_FILE: &str = "asusd.conf";
|
const CONFIG_FILE: &str = "asusd.conf";
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Default)]
|
#[derive(Deserialize, Serialize, Default)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
|
|||||||
@@ -7,30 +7,10 @@ use ron::ser::PrettyConfig;
|
|||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
static CONFIG_PATH_BASE: &str = "/etc/asusd/";
|
const CONFIG_PATH_BASE: &str = "/etc/asusd/";
|
||||||
|
|
||||||
/// Create a `PathBuf` for `file`. If the base config dir `CONFIG_PATH_BASE`
|
|
||||||
/// does not exist it is created.
|
|
||||||
fn config_file(file: &str) -> PathBuf {
|
|
||||||
let mut config = PathBuf::from(CONFIG_PATH_BASE);
|
|
||||||
if !config.exists() {
|
|
||||||
create_dir(config.as_path()).unwrap_or_else(|_| panic!("Could not create {config:?}"));
|
|
||||||
}
|
|
||||||
config.push(file);
|
|
||||||
config
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Open a config file as read/write. If the file or dir does not exist then
|
|
||||||
/// both are created.
|
|
||||||
fn config_file_open(file: PathBuf) -> File {
|
|
||||||
OpenOptions::new()
|
|
||||||
.read(true)
|
|
||||||
.write(true)
|
|
||||||
.create(true)
|
|
||||||
.open(file.clone())
|
|
||||||
.unwrap_or_else(|_| panic!("The file {file:?} or directory {CONFIG_PATH_BASE} is missing"))
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/// Config file helper traits. Only `new()` and `file_name()` are required to be
|
||||||
|
/// implemented, the rest are intended to be free methods.
|
||||||
pub trait StdConfig
|
pub trait StdConfig
|
||||||
where
|
where
|
||||||
Self: Serialize + DeserializeOwned,
|
Self: Serialize + DeserializeOwned,
|
||||||
@@ -40,18 +20,32 @@ where
|
|||||||
fn file_name() -> &'static str;
|
fn file_name() -> &'static str;
|
||||||
|
|
||||||
fn file_path() -> PathBuf {
|
fn file_path() -> PathBuf {
|
||||||
config_file(Self::file_name())
|
let mut config = PathBuf::from(CONFIG_PATH_BASE);
|
||||||
|
if !config.exists() {
|
||||||
|
create_dir(config.as_path())
|
||||||
|
.unwrap_or_else(|e| panic!("Could not create {CONFIG_PATH_BASE} {e}"));
|
||||||
|
}
|
||||||
|
config.push(Self::file_name());
|
||||||
|
config
|
||||||
}
|
}
|
||||||
|
|
||||||
fn file_open() -> File {
|
fn file_open() -> File {
|
||||||
config_file_open(Self::file_path())
|
OpenOptions::new()
|
||||||
|
.read(true)
|
||||||
|
.write(true)
|
||||||
|
.create(true)
|
||||||
|
.open(Self::file_path())
|
||||||
|
.unwrap_or_else(|e| panic!("Could not open {:?} {e}", Self::file_path()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read(&mut self) {
|
fn read(&mut self) {
|
||||||
let mut file = OpenOptions::new()
|
let mut file = match OpenOptions::new().read(true).open(Self::file_path()) {
|
||||||
.read(true)
|
Ok(data) => data,
|
||||||
.open(Self::file_path())
|
Err(err) => {
|
||||||
.unwrap_or_else(|err| panic!("Error reading {:?}: {}", Self::file_path(), err));
|
error!("Error reading {:?}: {}", Self::file_path(), err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
if let Ok(l) = file.read_to_string(&mut buf) {
|
if let Ok(l) = file.read_to_string(&mut buf) {
|
||||||
if l == 0 {
|
if l == 0 {
|
||||||
@@ -67,12 +61,23 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn write(&self) {
|
fn write(&self) {
|
||||||
let mut file = File::create(Self::file_path()).expect(&format!(
|
let mut file = match File::create(Self::file_path()) {
|
||||||
"Couldn't overwrite config {:?}",
|
Ok(data) => data,
|
||||||
Self::file_path()
|
Err(e) => {
|
||||||
));
|
error!(
|
||||||
let ron = ron::ser::to_string_pretty(&self, PrettyConfig::new().depth_limit(4))
|
"Couldn't overwrite config {:?}, error: {e}",
|
||||||
.expect("Parse config to RON failed");
|
Self::file_path()
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let ron = match ron::ser::to_string_pretty(&self, PrettyConfig::new().depth_limit(4)) {
|
||||||
|
Ok(data) => data,
|
||||||
|
Err(e) => {
|
||||||
|
error!("Parse {:?} to RON failed, error: {e}", Self::file_path());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
file.write_all(ron.as_bytes())
|
file.write_all(ron.as_bytes())
|
||||||
.unwrap_or_else(|err| error!("Could not write config: {}", err));
|
.unwrap_or_else(|err| error!("Could not write config: {}", err));
|
||||||
}
|
}
|
||||||
@@ -86,7 +91,7 @@ where
|
|||||||
);
|
);
|
||||||
let cfg_old = Self::file_path().to_string_lossy().to_string() + "-old";
|
let cfg_old = Self::file_path().to_string_lossy().to_string() + "-old";
|
||||||
std::fs::rename(Self::file_path(), cfg_old).unwrap_or_else(|err| {
|
std::fs::rename(Self::file_path(), cfg_old).unwrap_or_else(|err| {
|
||||||
panic!(
|
error!(
|
||||||
"Could not rename. Please remove {} then restart service: Error {}",
|
"Could not rename. Please remove {} then restart service: Error {}",
|
||||||
Self::file_name(),
|
Self::file_name(),
|
||||||
err
|
err
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
use std::fs::File;
|
|
||||||
use std::io::Write;
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use rog_anime::error::AnimeError;
|
use rog_anime::error::AnimeError;
|
||||||
@@ -8,8 +6,7 @@ use serde_derive::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::config_traits::{StdConfig, StdConfigLoad3};
|
use crate::config_traits::{StdConfig, StdConfigLoad3};
|
||||||
|
|
||||||
pub static CONFIG_FILE: &str = "anime.conf";
|
const CONFIG_FILE: &str = "anime.conf";
|
||||||
pub static ANIME_CACHE_PATH: &str = "/etc/asusd/anime-cache.conf";
|
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
pub struct AnimeConfigV341 {
|
pub struct AnimeConfigV341 {
|
||||||
@@ -141,7 +138,7 @@ impl Default for AnimeConfig {
|
|||||||
|
|
||||||
impl StdConfig for AnimeConfig {
|
impl StdConfig for AnimeConfig {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Self::create_default(&mut Self::file_open())
|
Self::create_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn file_name() -> &'static str {
|
fn file_name() -> &'static str {
|
||||||
@@ -162,7 +159,7 @@ impl AnimeConfig {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
fn create_default(file: &mut File) -> Self {
|
fn create_default() -> Self {
|
||||||
// create a default config here
|
// create a default config here
|
||||||
let config = AnimeConfig {
|
let config = AnimeConfig {
|
||||||
system: vec![],
|
system: vec![],
|
||||||
@@ -202,10 +199,7 @@ impl AnimeConfig {
|
|||||||
awake_enabled: true,
|
awake_enabled: true,
|
||||||
boot_anim_enabled: true,
|
boot_anim_enabled: true,
|
||||||
};
|
};
|
||||||
// Should be okay to unwrap this as is since it is a Default
|
config.write();
|
||||||
let json = serde_json::to_string_pretty(&config).unwrap();
|
|
||||||
file.write_all(json.as_bytes())
|
|
||||||
.unwrap_or_else(|_| panic!("Could not write {}", CONFIG_FILE));
|
|
||||||
config
|
config
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
use std::collections::{BTreeMap, HashSet};
|
use std::collections::{BTreeMap, HashSet};
|
||||||
use std::fs::File;
|
|
||||||
use std::io::Write;
|
|
||||||
|
|
||||||
use rog_aura::aura_detection::{LaptopLedData, ASUS_KEYBOARD_DEVICES};
|
use rog_aura::aura_detection::{LaptopLedData, ASUS_KEYBOARD_DEVICES};
|
||||||
use rog_aura::usb::{AuraDev1866, AuraDev19b6, AuraDevTuf, AuraDevice, AuraPowerDev};
|
use rog_aura::usb::{AuraDev1866, AuraDev19b6, AuraDevTuf, AuraDevice, AuraPowerDev};
|
||||||
@@ -11,7 +9,7 @@ use serde_derive::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::config_traits::{StdConfig, StdConfigLoad1};
|
use crate::config_traits::{StdConfig, StdConfigLoad1};
|
||||||
|
|
||||||
static CONFIG_FILE: &str = "aura.conf";
|
const CONFIG_FILE: &str = "aura.conf";
|
||||||
|
|
||||||
/// Enable/disable LED control in various states such as
|
/// Enable/disable LED control in various states such as
|
||||||
/// when the device is awake, suspended, shutting down or
|
/// when the device is awake, suspended, shutting down or
|
||||||
@@ -190,7 +188,7 @@ impl Default for AuraConfig {
|
|||||||
|
|
||||||
impl StdConfig for AuraConfig {
|
impl StdConfig for AuraConfig {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Self::create_default(&mut Self::file_open(), &LaptopLedData::get_data())
|
Self::create_default(&LaptopLedData::get_data())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn file_name() -> &'static str {
|
fn file_name() -> &'static str {
|
||||||
@@ -201,7 +199,7 @@ impl StdConfig for AuraConfig {
|
|||||||
impl StdConfigLoad1<AuraConfig> for AuraConfig {}
|
impl StdConfigLoad1<AuraConfig> for AuraConfig {}
|
||||||
|
|
||||||
impl AuraConfig {
|
impl AuraConfig {
|
||||||
fn create_default(file: &mut File, support_data: &LaptopLedData) -> Self {
|
fn create_default(support_data: &LaptopLedData) -> Self {
|
||||||
// create a default config here
|
// create a default config here
|
||||||
let mut config = AuraConfig::default();
|
let mut config = AuraConfig::default();
|
||||||
|
|
||||||
@@ -231,11 +229,7 @@ impl AuraConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
config.write();
|
||||||
// Should be okay to unwrap this as is since it is a Default
|
|
||||||
let json = serde_json::to_string(&config).unwrap();
|
|
||||||
file.write_all(json.as_bytes())
|
|
||||||
.unwrap_or_else(|_| panic!("Could not write {}", CONFIG_FILE));
|
|
||||||
config
|
config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,15 +10,12 @@ const CONFIG_FAN_FILE: &str = "fan_curves.conf";
|
|||||||
pub struct ProfileConfig {
|
pub struct ProfileConfig {
|
||||||
/// For restore on boot
|
/// For restore on boot
|
||||||
pub active_profile: Profile,
|
pub active_profile: Profile,
|
||||||
/// States to restore
|
|
||||||
pub fan_curves: Option<FanCurveProfiles>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StdConfig for ProfileConfig {
|
impl StdConfig for ProfileConfig {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
active_profile: Profile::Balanced,
|
active_profile: Profile::Balanced,
|
||||||
fan_curves: None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use crate::GetSupported;
|
|||||||
|
|
||||||
pub struct CtrlPlatformProfile {
|
pub struct CtrlPlatformProfile {
|
||||||
pub profile_config: ProfileConfig,
|
pub profile_config: ProfileConfig,
|
||||||
|
pub fan_config: Option<FanCurveProfiles>,
|
||||||
pub platform: AsusPlatform,
|
pub platform: AsusPlatform,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,21 +52,26 @@ impl CtrlPlatformProfile {
|
|||||||
if platform.has_platform_profile() || platform.has_throttle_thermal_policy() {
|
if platform.has_platform_profile() || platform.has_throttle_thermal_policy() {
|
||||||
info!("Device has profile control available");
|
info!("Device has profile control available");
|
||||||
|
|
||||||
let mut controller = CtrlPlatformProfile { profile_config: config, platform };
|
let mut controller = CtrlPlatformProfile {
|
||||||
|
profile_config: config,
|
||||||
|
fan_config: None,
|
||||||
|
platform,
|
||||||
|
};
|
||||||
if FanCurveProfiles::get_device().is_ok() {
|
if FanCurveProfiles::get_device().is_ok() {
|
||||||
info!("Device has fan curves available");
|
info!("Device has fan curves available");
|
||||||
if controller.profile_config.fan_curves.is_none() {
|
if controller.fan_config.is_none() {
|
||||||
controller.profile_config.fan_curves = Some(Default::default());
|
controller.fan_config = Some(Default::default());
|
||||||
for _ in [Profile::Balanced, Profile::Performance, Profile::Quiet] {
|
for _ in [Profile::Balanced, Profile::Performance, Profile::Quiet] {
|
||||||
controller.set_next_profile()?;
|
controller.set_next_profile()?;
|
||||||
controller.set_active_curve_to_defaults()?;
|
controller.set_active_curve_to_defaults()?;
|
||||||
|
|
||||||
let active = Profile::get_active_profile().unwrap_or(Profile::Balanced);
|
let active = Profile::get_active_profile().unwrap_or(Profile::Balanced);
|
||||||
if let Some(curves) = controller.profile_config.fan_curves.as_ref() {
|
if let Some(curves) = controller.fan_config.as_ref() {
|
||||||
info!(
|
info!(
|
||||||
"{active:?}: {}",
|
"{active:?}: {}",
|
||||||
String::from(curves.get_fan_curves_for(active))
|
String::from(curves.get_fan_curves_for(active))
|
||||||
);
|
);
|
||||||
|
curves.write();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,6 +85,9 @@ impl CtrlPlatformProfile {
|
|||||||
|
|
||||||
pub fn save_config(&self) {
|
pub fn save_config(&self) {
|
||||||
self.profile_config.write();
|
self.profile_config.write();
|
||||||
|
if let Some(fans) = self.fan_config.as_ref() {
|
||||||
|
fans.write();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Toggle to next profile in list. This will first read the config, switch,
|
/// Toggle to next profile in list. This will first read the config, switch,
|
||||||
@@ -105,18 +114,24 @@ impl CtrlPlatformProfile {
|
|||||||
|
|
||||||
/// Set the curve for the active profile active
|
/// Set the curve for the active profile active
|
||||||
pub(super) fn write_profile_curve_to_platform(&mut self) -> Result<(), RogError> {
|
pub(super) fn write_profile_curve_to_platform(&mut self) -> Result<(), RogError> {
|
||||||
if let Some(curves) = &mut self.profile_config.fan_curves {
|
if let Some(curves) = &mut self.fan_config {
|
||||||
if let Ok(mut device) = FanCurveProfiles::get_device() {
|
if let Ok(mut device) = FanCurveProfiles::get_device() {
|
||||||
curves.write_profile_curve_to_platform(self.profile_config.active_profile, &mut device)?;
|
curves.write_profile_curve_to_platform(
|
||||||
|
self.profile_config.active_profile,
|
||||||
|
&mut device,
|
||||||
|
)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn set_active_curve_to_defaults(&mut self) -> Result<(), RogError> {
|
pub(super) fn set_active_curve_to_defaults(&mut self) -> Result<(), RogError> {
|
||||||
if let Some(curves) = self.profile_config.fan_curves.as_mut() {
|
if let Some(curves) = self.fan_config.as_mut() {
|
||||||
if let Ok(mut device) = FanCurveProfiles::get_device() {
|
if let Ok(mut device) = FanCurveProfiles::get_device() {
|
||||||
curves.set_active_curve_to_defaults(self.profile_config.active_profile, &mut device)?;
|
curves.set_active_curve_to_defaults(
|
||||||
|
self.profile_config.active_profile,
|
||||||
|
&mut device,
|
||||||
|
)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ impl ProfileZbus {
|
|||||||
async fn enabled_fan_profiles(&mut self) -> zbus::fdo::Result<Vec<Profile>> {
|
async fn enabled_fan_profiles(&mut self) -> zbus::fdo::Result<Vec<Profile>> {
|
||||||
let mut ctrl = self.0.lock().await;
|
let mut ctrl = self.0.lock().await;
|
||||||
ctrl.profile_config.read();
|
ctrl.profile_config.read();
|
||||||
if let Some(curves) = &ctrl.profile_config.fan_curves {
|
if let Some(curves) = &ctrl.fan_config {
|
||||||
return Ok(curves.get_enabled_curve_profiles());
|
return Ok(curves.get_enabled_curve_profiles());
|
||||||
}
|
}
|
||||||
Err(Error::Failed(UNSUPPORTED_MSG.to_owned()))
|
Err(Error::Failed(UNSUPPORTED_MSG.to_owned()))
|
||||||
@@ -96,7 +96,7 @@ impl ProfileZbus {
|
|||||||
) -> zbus::fdo::Result<()> {
|
) -> zbus::fdo::Result<()> {
|
||||||
let mut ctrl = self.0.lock().await;
|
let mut ctrl = self.0.lock().await;
|
||||||
ctrl.profile_config.read();
|
ctrl.profile_config.read();
|
||||||
if let Some(curves) = &mut ctrl.profile_config.fan_curves {
|
if let Some(curves) = &mut ctrl.fan_config {
|
||||||
curves.set_profile_curve_enabled(profile, enabled);
|
curves.set_profile_curve_enabled(profile, enabled);
|
||||||
|
|
||||||
ctrl.write_profile_curve_to_platform()
|
ctrl.write_profile_curve_to_platform()
|
||||||
@@ -114,7 +114,7 @@ impl ProfileZbus {
|
|||||||
async fn fan_curve_data(&mut self, profile: Profile) -> zbus::fdo::Result<FanCurveSet> {
|
async fn fan_curve_data(&mut self, profile: Profile) -> zbus::fdo::Result<FanCurveSet> {
|
||||||
let mut ctrl = self.0.lock().await;
|
let mut ctrl = self.0.lock().await;
|
||||||
ctrl.profile_config.read();
|
ctrl.profile_config.read();
|
||||||
if let Some(curves) = &ctrl.profile_config.fan_curves {
|
if let Some(curves) = &ctrl.fan_config {
|
||||||
let curve = curves.get_fan_curves_for(profile);
|
let curve = curves.get_fan_curves_for(profile);
|
||||||
return Ok(curve.clone());
|
return Ok(curve.clone());
|
||||||
}
|
}
|
||||||
@@ -126,7 +126,7 @@ impl ProfileZbus {
|
|||||||
async fn set_fan_curve(&self, profile: Profile, curve: CurveData) -> zbus::fdo::Result<()> {
|
async fn set_fan_curve(&self, profile: Profile, curve: CurveData) -> zbus::fdo::Result<()> {
|
||||||
let mut ctrl = self.0.lock().await;
|
let mut ctrl = self.0.lock().await;
|
||||||
ctrl.profile_config.read();
|
ctrl.profile_config.read();
|
||||||
if let Some(curves) = &mut ctrl.profile_config.fan_curves {
|
if let Some(curves) = &mut ctrl.fan_config {
|
||||||
curves
|
curves
|
||||||
.save_fan_curve(curve, profile)
|
.save_fan_curve(curve, profile)
|
||||||
.map_err(|err| zbus::fdo::Error::Failed(err.to_string()))?;
|
.map_err(|err| zbus::fdo::Error::Failed(err.to_string()))?;
|
||||||
@@ -240,7 +240,7 @@ impl crate::Reloadable for ProfileZbus {
|
|||||||
async fn reload(&mut self) -> Result<(), RogError> {
|
async fn reload(&mut self) -> Result<(), RogError> {
|
||||||
let mut ctrl = self.0.lock().await;
|
let mut ctrl = self.0.lock().await;
|
||||||
let active = ctrl.profile_config.active_profile;
|
let active = ctrl.profile_config.active_profile;
|
||||||
if let Some(curves) = &mut ctrl.profile_config.fan_curves {
|
if let Some(curves) = &mut ctrl.fan_config {
|
||||||
if let Ok(mut device) = FanCurveProfiles::get_device() {
|
if let Ok(mut device) = FanCurveProfiles::get_device() {
|
||||||
// There is a possibility that the curve was default zeroed, so this call
|
// 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
|
// initialises the data from system read and we need to save it
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ pub enum RogError {
|
|||||||
SystemdUnitAction(String),
|
SystemdUnitAction(String),
|
||||||
SystemdUnitWaitTimeout(String),
|
SystemdUnitWaitTimeout(String),
|
||||||
Command(String, std::io::Error),
|
Command(String, std::io::Error),
|
||||||
|
ParseRon(ron::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for RogError {
|
impl fmt::Display for RogError {
|
||||||
@@ -82,6 +83,7 @@ impl fmt::Display for RogError {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
RogError::Command(func, error) => write!(f, "Command exec error: {}: {}", func, error),
|
RogError::Command(func, error) => write!(f, "Command exec error: {}: {}", func, error),
|
||||||
|
RogError::ParseRon(error) => write!(f, "Parse config error: {}", error),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -118,6 +120,12 @@ impl From<std::io::Error> for RogError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<ron::Error> for RogError {
|
||||||
|
fn from(err: ron::Error) -> Self {
|
||||||
|
RogError::ParseRon(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<RogError> for zbus::fdo::Error {
|
impl From<RogError> for zbus::fdo::Error {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(err: RogError) -> Self {
|
fn from(err: RogError) -> Self {
|
||||||
|
|||||||
Reference in New Issue
Block a user