use serde::{Deserialize, Serialize};
use thiserror::Error;
#[derive(Debug, Clone, Error, Serialize, Deserialize)]
pub enum WriteError {
#[error("HID transport error: {0}")]
Hid(String),
#[error("no connected device matched the route")]
DeviceNotFound,
#[error("device at index {index:#04x} did not respond to HID++")]
DeviceUnreachable {
index: u8,
},
#[error("device does not expose HID++ feature {feature_hex:#06x}")]
FeatureUnsupported {
feature_hex: u16,
},
#[error("device returned no supported DPI values")]
EmptyDpiList,
#[error("HID++ protocol error: {0}")]
Hidpp(String),
#[error("HID++ feature error during {operation:?} for feature {feature_hex:#06x}: {kind:?}")]
HidppFeature {
operation: HidppOperation,
feature_hex: u16,
kind: HidppFeatureErrorKind,
},
#[error("HID++ unsupported response during {operation:?} for feature {feature_hex:#06x}")]
UnsupportedResponse {
operation: HidppOperation,
feature_hex: u16,
},
#[error("HID++ request timed out during {operation:?}")]
RequestTimedOut {
operation: HidppOperation,
},
#[error("tokio runtime init failed: {message}")]
RuntimeInit {
message: String,
},
#[error("background agent is unavailable")]
AgentUnavailable,
#[error("invalid light value for {control}: {value}")]
InvalidLightValue {
control: String,
value: u16,
},
#[error("light control is unsupported: {control}")]
LightUnsupported {
control: String,
},
#[error("multiple raw HID devices matched the route")]
AmbiguousRawDevice,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum HidppOperation {
ResolveFeature,
DumpFeatures,
ReadDpi,
ReadDpiCapabilities,
WriteDpi,
ReadSmartShift,
WriteSmartShift,
Lighting,
ReadWheelMode,
WriteWheelMode,
ReadBacklight,
WriteBacklight,
WriteFnLock,
Light,
PlayHaptic,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum HidppFeatureErrorKind {
NoError,
Unknown,
InvalidArgument,
OutOfRange,
HwError,
LogitechInternal,
InvalidFeatureIndex,
InvalidFunctionId,
Busy,
Unsupported,
Unrecognized,
}