Fluke/dbus refactor

This commit is contained in:
Luke Jones
2023-12-03 20:44:01 +00:00
parent f6e4cc0626
commit 0a69c23288
143 changed files with 5421 additions and 10343 deletions

View File

@@ -1,5 +1,7 @@
use std::fmt;
use zbus::fdo::Error as FdoErr;
pub type Result<T> = std::result::Result<T, PlatformError>;
#[derive(Debug)]
@@ -19,6 +21,7 @@ pub enum PlatformError {
Io(std::io::Error),
NoAuraKeyboard,
NoAuraNode,
CPU(String),
}
impl fmt::Display for PlatformError {
@@ -45,6 +48,7 @@ impl fmt::Display for PlatformError {
PlatformError::IoPath(path, detail) => write!(f, "{} {}", path, detail),
PlatformError::NoAuraKeyboard => write!(f, "No supported Aura keyboard"),
PlatformError::NoAuraNode => write!(f, "No Aura keyboard node found"),
PlatformError::CPU(s) => write!(f, "CPU control: {s}"),
}
}
}
@@ -62,3 +66,13 @@ impl From<std::io::Error> for PlatformError {
PlatformError::Io(err)
}
}
impl From<PlatformError> for FdoErr {
fn from(error: PlatformError) -> Self {
log::error!("PlatformError: got: {error}");
match error {
PlatformError::NotSupported => FdoErr::NotSupported("".to_owned()),
_ => FdoErr::Failed(format!("Failed with {error}")),
}
}
}