Fix clippy warnings in code configured out behind async feature

This commit is contained in:
ninjadev64 committed 2025-03-01 17:38:19 +00:00
1 parent b394dda5ac
commit 401b25daaf
3 files changed
+21 -21

No files matched your search

+19 -19
View File
@@ -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<String, StreamDeckError> {
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<String, StreamDeckError> {
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<String, StreamDeckError> {
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<String, StreamDeckError> {
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
+1 -1
View File
@@ -104,6 +104,6 @@ impl ImageRect {
#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub fn from_image_async(image: DynamicImage) -> Result<ImageRect, StreamDeckError> {
Ok(tokio::task::block_in_place(move || ImageRect::from_image(image))?)
tokio::task::block_in_place(move || ImageRect::from_image(image))
}
}
+1 -1
View File
@@ -192,7 +192,7 @@ pub fn ajazz03_read_input(kind: &Kind, input: u8) -> Result<StreamDeckInput, Str
match input {
(0..=6) | 0x25 | 0x30 | 0x31 => 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),
}
}