diff --git a/src/asynchronous.rs b/src/asynchronous.rs index 2b7679a..75b7a39 100644 --- a/src/asynchronous.rs +++ b/src/asynchronous.rs @@ -24,7 +24,7 @@ pub fn refresh_device_list_async(hidapi: &mut HidApi) -> HidResult<()> { /// /// **WARNING:** To refresh the list, use [refresh_device_list] pub fn list_devices_async(hidapi: &HidApi) -> Vec<(Kind, String)> { - block_in_place(move || list_devices(&hidapi)) + block_in_place(move || list_devices(hidapi)) } /// Stream Deck interface suitable to be used in async, uses [block_in_place](block_in_place) @@ -58,25 +58,25 @@ impl AsyncStreamDeck { /// Returns manufacturer string of the device pub async fn manufacturer(&self) -> Result { let device = self.device.lock().await; - Ok(block_in_place(move || device.manufacturer())?) + block_in_place(move || device.manufacturer()) } /// Returns product string of the device pub async fn product(&self) -> Result { let device = self.device.lock().await; - Ok(block_in_place(move || device.product())?) + block_in_place(move || device.product()) } /// Returns serial number of the device pub async fn serial_number(&self) -> Result { let device = self.device.lock().await; - Ok(block_in_place(move || device.serial_number())?) + block_in_place(move || device.serial_number()) } /// Returns firmware version of the StreamDeck pub async fn firmware_version(&self) -> Result { let device = self.device.lock().await; - Ok(block_in_place(move || device.firmware_version())?) + block_in_place(move || device.firmware_version()) } /// Reads button states, awaits until there's data. @@ -97,27 +97,27 @@ impl AsyncStreamDeck { /// Resets the device pub async fn reset(&self) -> Result<(), StreamDeckError> { let device = self.device.lock().await; - Ok(block_in_place(move || device.reset())?) + block_in_place(move || device.reset()) } /// Sets brightness of the device, value range is 0 - 100 pub async fn set_brightness(&self, percent: u8) -> Result<(), StreamDeckError> { let device = self.device.lock().await; - Ok(block_in_place(move || device.set_brightness(percent))?) + block_in_place(move || device.set_brightness(percent)) } /// Writes image data to Stream Deck device, changes must be flushed with `.flush()` before /// they will appear on the device! pub async fn write_image(&self, key: u8, image_data: &[u8]) -> Result<(), StreamDeckError> { let device = self.device.lock().await; - Ok(block_in_place(move || device.write_image(key, image_data))?) + block_in_place(move || device.write_image(key, image_data)) } /// Writes image data to Stream Deck device's lcd strip/screen as region. /// Only Stream Deck Plus supports writing LCD regions, for Stream Deck Neo use write_lcd_fill pub async fn write_lcd(&self, x: u16, y: u16, rect: &ImageRect) -> Result<(), StreamDeckError> { let device = self.device.lock().await; - Ok(block_in_place(move || device.write_lcd(x, y, rect))?) + block_in_place(move || device.write_lcd(x, y, rect)) } /// Writes image data to Stream Deck device's lcd strip/screen as full fill @@ -130,21 +130,21 @@ impl AsyncStreamDeck { /// ``` pub async fn write_lcd_fill(&self, image_data: &[u8]) -> Result<(), StreamDeckError> { let device = self.device.lock().await; - Ok(block_in_place(move || device.write_lcd_fill(image_data))?) + block_in_place(move || device.write_lcd_fill(image_data)) } /// Sets button's image to blank, changes must be flushed with `.flush()` before /// they will appear on the device! pub async fn clear_button_image(&self, key: u8) -> Result<(), StreamDeckError> { let device = self.device.lock().await; - Ok(block_in_place(move || device.clear_button_image(key))?) + block_in_place(move || device.clear_button_image(key)) } /// Sets blank images to every button, changes must be flushed with `.flush()` before /// they will appear on the device! pub async fn clear_all_button_images(&self) -> Result<(), StreamDeckError> { let device = self.device.lock().await; - Ok(block_in_place(move || device.clear_all_button_images())?) + block_in_place(move || device.clear_all_button_images()) } /// Sets specified button's image, changes must be flushed with `.flush()` before @@ -153,43 +153,43 @@ impl AsyncStreamDeck { let image = convert_image_async(self.kind, image)?; let device = self.device.lock().await; - Ok(block_in_place(move || device.write_image(key, &image))?) + block_in_place(move || device.write_image(key, &image)) } /// Set logo image pub async fn set_logo_image(&self, image: DynamicImage) -> Result<(), StreamDeckError> { let device = self.device.lock().await; - Ok(block_in_place(move || device.set_logo_image(image))?) + block_in_place(move || device.set_logo_image(image)) } /// Sets specified touch point's led strip color pub async fn set_touchpoint_color(&self, point: u8, red: u8, green: u8, blue: u8) -> Result<(), StreamDeckError> { let device = self.device.lock().await; - Ok(block_in_place(move || device.set_touchpoint_color(point, red, green, blue))?) + block_in_place(move || device.set_touchpoint_color(point, red, green, blue)) } /// Sleeps the device pub async fn sleep(&self) -> Result<(), StreamDeckError> { let device = self.device.lock().await; - Ok(block_in_place(move || device.sleep())?) + block_in_place(move || device.sleep()) } /// Make periodic events to the device, to keep it alive pub async fn keep_alive(&self) -> Result<(), StreamDeckError> { let device = self.device.lock().await; - Ok(block_in_place(move || device.keep_alive())?) + block_in_place(move || device.keep_alive()) } /// Shutdown the device pub async fn shutdown(&self) -> Result<(), StreamDeckError> { let device = self.device.lock().await; - Ok(block_in_place(move || device.shutdown())?) + block_in_place(move || device.shutdown()) } /// Flushes the button's image to the device pub async fn flush(&self) -> Result<(), StreamDeckError> { let device = self.device.lock().await; - Ok(block_in_place(move || device.flush())?) + block_in_place(move || device.flush()) } /// Returns button state reader for this device diff --git a/src/images.rs b/src/images.rs index 3ece1a1..ca58f3b 100644 --- a/src/images.rs +++ b/src/images.rs @@ -104,6 +104,6 @@ impl ImageRect { #[cfg(feature = "async")] #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub fn from_image_async(image: DynamicImage) -> Result { - Ok(tokio::task::block_in_place(move || ImageRect::from_image(image))?) + tokio::task::block_in_place(move || ImageRect::from_image(image)) } } diff --git a/src/util.rs b/src/util.rs index cfead1f..4f13551 100644 --- a/src/util.rs +++ b/src/util.rs @@ -192,7 +192,7 @@ pub fn ajazz03_read_input(kind: &Kind, input: u8) -> Result ajazz03_read_button_press(kind, input), 0x90 | 0x91 | 0x50 | 0x51 | 0x60 | 0x61 => ajazz03_read_encoder_value(kind, input), - 0x33 | 0x34 | 0x35 => ajazz03_read_encoder_press(kind, input), + 0x33..=0x35 => ajazz03_read_encoder_press(kind, input), _ => Err(StreamDeckError::BadData), } }