mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Create rog-platform, refactor rogcc ipc-file handling
- Create new rog-platform crate to manage all i/o in a universal way + kbd-led handling + platform handling (asus-nb-wmi) + hidraw + usbraw - Refactor how ROGCC handles IPC for background open, run-in-bg
This commit is contained in:
51
rog-platform/src/error.rs
Normal file
51
rog-platform/src/error.rs
Normal file
@@ -0,0 +1,51 @@
|
||||
use std::fmt;
|
||||
|
||||
pub type Result<T> = std::result::Result<T, PlatformError>;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum PlatformError {
|
||||
ParseVendor,
|
||||
ParseNum,
|
||||
Udev(String, std::io::Error),
|
||||
USB(rusb::Error),
|
||||
Path(String, std::io::Error),
|
||||
Read(String, std::io::Error),
|
||||
Write(String, std::io::Error),
|
||||
NotSupported,
|
||||
AttrNotFound(String),
|
||||
MissingFunction(String),
|
||||
MissingLedBrightNode(String, std::io::Error),
|
||||
Io(String, std::io::Error),
|
||||
NoAuraKeyboard,
|
||||
NoAuraNode,
|
||||
}
|
||||
|
||||
impl fmt::Display for PlatformError {
|
||||
// This trait requires `fmt` with this exact signature.
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
PlatformError::ParseVendor => write!(f, "Parse gfx vendor error"),
|
||||
PlatformError::ParseNum => write!(f, "Parse number error"),
|
||||
PlatformError::Udev(deets, error) => write!(f, "udev {}: {}", deets, error),
|
||||
PlatformError::USB(error) => write!(f, "usb {}", error),
|
||||
PlatformError::Path(path, error) => write!(f, "Path {}: {}", path, error),
|
||||
PlatformError::Read(path, error) => write!(f, "Read {}: {}", path, error),
|
||||
PlatformError::Write(path, error) => write!(f, "Write {}: {}", path, error),
|
||||
PlatformError::NotSupported => write!(f, "Not supported"),
|
||||
PlatformError::AttrNotFound(deets) => write!(f, "Attribute not found: {}", deets),
|
||||
PlatformError::MissingFunction(deets) => write!(f, "Missing functionality: {}", deets),
|
||||
PlatformError::MissingLedBrightNode(path, error) => write!(f, "Led node at {} is missing, please check you have the required patch or dkms module installed: {}", path, error),
|
||||
PlatformError::Io(path, detail) => write!(f, "std::io error: {} {}", path, detail),
|
||||
PlatformError::NoAuraKeyboard => write!(f, "No supported Aura keyboard"),
|
||||
PlatformError::NoAuraNode => write!(f, "No Aura keyboard node found"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for PlatformError {}
|
||||
|
||||
impl From<rusb::Error> for PlatformError {
|
||||
fn from(err: rusb::Error) -> Self {
|
||||
PlatformError::USB(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user