- Sleep vor HID-Reads entfernt — read_timeout reicht als Synchronisation, spart ~300ms pro Aufruf - udev-Regel: MODE 0660 + GROUP plugdev statt world-writable 0666 - Eigener CorsairError::SidetoneNotFound für fehlende ALSA-Controls - Response-Validierung vorbereitet (parse_response_validated), Korrelation noch deaktiviert da Response-Format andere Endpoint-IDs nutzt als das Request-Format (0x00/0x01 vs 0x08/0x09) - Protokoll-Doku zum Response-Format korrigiert - 18 neue Tests für output.rs (Waybar-JSON Formatierung + Grenzwerte)
34 lines
1.1 KiB
Rust
34 lines
1.1 KiB
Rust
// ABOUTME: Zentrales Error-Handling für corsairctl.
|
|
// ABOUTME: Definiert CorsairError als thiserror-Enum für alle Fehlerfälle.
|
|
|
|
use thiserror::Error;
|
|
|
|
#[derive(Debug, Error)]
|
|
pub enum CorsairError {
|
|
#[error("Kein Corsair-Gerät gefunden (VID 0x1B1C, Interface 3)")]
|
|
DeviceNotFound,
|
|
|
|
#[error("ALSA Sidetone-Control nicht gefunden — kein Corsair USB-Audio-Interface erkannt")]
|
|
SidetoneNotFound,
|
|
|
|
#[error("Headset antwortet nicht — möglicherweise ausgeschaltet")]
|
|
HeadsetOffline,
|
|
|
|
#[error("Gerät-Fehler: Property 0x{property:02X} nicht unterstützt")]
|
|
PropertyNotSupported { property: u8 },
|
|
|
|
#[error("Ungültige Antwort: erwartet mindestens {expected} Bytes, bekommen {got}")]
|
|
ResponseTooShort { expected: usize, got: usize },
|
|
|
|
#[error("Unerwartete Antwort: Endpoint 0x{endpoint:02X}, Command 0x{command:02X}")]
|
|
UnexpectedResponse { endpoint: u8, command: u8 },
|
|
|
|
#[error("HID-Fehler: {0}")]
|
|
Hid(#[from] hidapi::HidError),
|
|
|
|
#[error("ALSA-Fehler: {0}")]
|
|
Alsa(#[from] alsa::Error),
|
|
}
|
|
|
|
pub type Result<T> = std::result::Result<T, CorsairError>;
|