From 17941dac32feec62b27785659da9713ffafd904c Mon Sep 17 00:00:00 2001 From: yorelog Date: Sat, 10 Jan 2026 12:36:02 +0000 Subject: [PATCH] update dependency and fix warning --- Cargo.toml | 4 ++-- src/auth.rs | 2 +- src/client.rs | 33 ++++++++++++++++++++------------- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index dbf8d87..c961e07 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,9 +18,9 @@ crate-type = ["cdylib", "rlib"] tokio = { version = "1", features = ["rt-multi-thread", "sync", "time", "net", "io-util", "macros"] } bytes = "1" log = "0.4" -thiserror = "1.0" # Error handling +thiserror = "2.0" # Error handling des = "0.8" # DES encryption for VNC auth -rand = "0.8" # Random number generation for auth +rand = "0.9" # Random number generation for auth flate2 = "1.0" # Zlib compression for Tight encoding rfb-encodings = "0.1.6" # RFB encoding implementations diff --git a/src/auth.rs b/src/auth.rs index 16d2841..b5966e0 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -68,7 +68,7 @@ impl VncAuth { /// A `[u8; 16]` array containing the random challenge bytes. #[allow(clippy::unused_self)] // Kept as method for API consistency with other VncAuthenticator methods pub fn generate_challenge(&self) -> [u8; 16] { - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); let mut challenge = [0u8; 16]; rng.fill(&mut challenge); challenge diff --git a/src/client.rs b/src/client.rs index 08d3f9e..60ecf89 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1118,13 +1118,15 @@ impl VncClient { not(feature = "debug-logging"), allow(unused_variables, unused_assignments) )] - let mut total_pixels = 0u64; + #[cfg(feature = "debug-logging")] + { + let mut total_pixels = 0u64; + let mut copy_rect_count = 0; + } #[cfg_attr( not(feature = "debug-logging"), allow(unused_variables, unused_assignments) )] - let mut copy_rect_count = 0; - // Load quality/compression settings atomically let jpeg_quality = self.jpeg_quality.load(Ordering::Relaxed); let compression_level = self.compression_level.load(Ordering::Relaxed); @@ -1155,9 +1157,11 @@ impl VncClient { // CopyRect data is just src_x and src_y response.put_u16(src_x); response.put_u16(src_y); - - total_pixels += u64::from(region.width) * u64::from(region.height); - copy_rect_count += 1; + #[cfg(feature = "debug-logging")] + { + total_pixels += u64::from(region.width) * u64::from(region.height); + copy_rect_count += 1; + } } } @@ -1223,11 +1227,10 @@ impl VncClient { rect.write_header(&mut response); response.extend_from_slice(encoded); - - total_pixels += u64::from(*w) * u64::from(*h); - #[cfg(feature = "debug-logging")] { + total_pixels += u64::from(*w) * u64::from(*h); + rect_count += 1; } } @@ -1323,8 +1326,10 @@ impl VncClient { // Write encoder output (background color + subrectangle data) response.extend_from_slice(&encoded); - - total_pixels += u64::from(tile_width) * u64::from(tile_height); + #[cfg(feature = "debug-logging")] + { + total_pixels += u64::from(tile_width) * u64::from(tile_height); + } } x += tile_width; @@ -1705,8 +1710,10 @@ impl VncClient { }; rect.write_header(&mut response); response.extend_from_slice(&encoded); - - total_pixels += u64::from(region.width) * u64::from(region.height); + #[cfg(feature = "debug-logging")] + { + total_pixels += u64::from(region.width) * u64::from(region.height); + } } }