diff --git a/Cargo.toml b/Cargo.toml index 97d096a..6485eb1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,9 @@ async = [ "tokio/time" ] +[dev-dependencies] +tokio = { version = "1", features = ["macros", "rt-multi-thread", "time"] } + [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] diff --git a/examples/async/src/main.rs b/examples/async.rs similarity index 94% rename from examples/async/src/main.rs rename to examples/async.rs index ac6a792..1586e60 100644 --- a/examples/async/src/main.rs +++ b/examples/async.rs @@ -1,3 +1,6 @@ +#[cfg(not(feature = "async"))] +compile_error!("The `async` feature must be enabled to compile this example."); + use std::time::Duration; use image::open; @@ -23,17 +26,17 @@ async fn main() { device.clear_all_button_images().await.unwrap(); // Use image-rs to load an image - let image = open("no-place-like-localhost.jpg").unwrap(); + let image = open("examples/no-place-like-localhost.jpg").unwrap(); let alternative = image.grayscale().brighten(-50); println!("Key count: {}", kind.key_count()); // Write it to the device - for i in 0..kind.key_count() as u8 { + for i in 0..kind.key_count() { device.set_button_image(i, image.clone()).await.unwrap(); } println!("Touch point count: {}", kind.touchpoint_count()); - for i in 0..kind.touchpoint_count() as u8 { + for i in 0..kind.touchpoint_count() { device.set_touchpoint_color(i, 255, 255, 255).await.unwrap(); } @@ -72,7 +75,7 @@ async fn main() { previous = index; index += 1; - if index >= kind.key_count() as u8 { + if index >= kind.key_count() { index = 0; } } diff --git a/examples/async/Cargo.toml b/examples/async/Cargo.toml deleted file mode 100644 index 4eda67e..0000000 --- a/examples/async/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "async" -edition = "2021" - -[dependencies] -image = { version = "0.25.1", default-features = false, features = [ - "bmp", - "jpeg", -] } -tokio = { version = "1", optional = false, features = ["full"] } -async-recursion = { version = "1.0.2", optional = false } -elgato-streamdeck = { path = "../../", features = ["async"] } diff --git a/examples/async/no-place-like-localhost.jpg b/examples/no-place-like-localhost.jpg similarity index 100% rename from examples/async/no-place-like-localhost.jpg rename to examples/no-place-like-localhost.jpg diff --git a/examples/simple/src/main.rs b/examples/simple.rs similarity index 95% rename from examples/simple/src/main.rs rename to examples/simple.rs index ec1fd84..0c3b20e 100644 --- a/examples/simple/src/main.rs +++ b/examples/simple.rs @@ -22,16 +22,16 @@ fn main() { device.set_brightness(50).unwrap(); device.clear_all_button_images().unwrap(); // Use image-rs to load an image - let image = open("no-place-like-localhost.jpg").unwrap(); + let image = open("examples/no-place-like-localhost.jpg").unwrap(); println!("Key count: {}", kind.key_count()); // Write it to the device - for i in 0..kind.key_count() as u8 { + for i in 0..kind.key_count() { device.set_button_image(i, image.clone()).unwrap(); } println!("Touch point count: {}", kind.touchpoint_count()); - for i in 0..kind.touchpoint_count() as u8 { + for i in 0..kind.touchpoint_count() { device.set_touchpoint_color(i, 255, 255, 255).unwrap(); } @@ -53,6 +53,7 @@ fn main() { // Flush device.flush().unwrap(); + #[allow(clippy::arc_with_non_send_sync)] let device = Arc::new(device); { let reader = device.get_reader(); diff --git a/examples/simple/Cargo.toml b/examples/simple/Cargo.toml deleted file mode 100644 index 00ede7c..0000000 --- a/examples/simple/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "simple" -edition = "2021" - -[dependencies] -image = { version = "0.25.1", default-features = false, features = [ - "bmp", - "jpeg", -] } -elgato-streamdeck = { path = "../../" } diff --git a/examples/simple/no-place-like-localhost.jpg b/examples/simple/no-place-like-localhost.jpg deleted file mode 100644 index 037d5c0..0000000 Binary files a/examples/simple/no-place-like-localhost.jpg and /dev/null differ