- pub fn new(api: &hidapi::HidApi, motherboard: Motherboard) -> Self {
- let device =
- Device {
- device: api
- .open(
- VID,
- match motherboard {
- Motherboard::Asus650e => PID_650_E,
- Motherboard::AsusCrosshairVIIIHero => PID_CROSSHAIR,
- },
- )
- .unwrap(),
- motherboard,
- };
-
- device.set_fixed_mode();
- device
+ pub fn new(api: &hidapi::HidApi, motherboard: Motherboard) -> anyhow::Result<Self> {
+ let device = Device {
+ device: api.open(
+ VID,
+ match motherboard {
+ Motherboard::Asus650e => PID_650_E,
+ Motherboard::AsusCrosshairVIIIHero => PID_CROSSHAIR,
+ },
+ )?,
+ motherboard,
+ };
+
+ device.set_fixed_mode()?;
+ Ok(device)