From 9f113bdb93a07a47a0539cd4d5b2e58c36481201 Mon Sep 17 00:00:00 2001 From: LIAUD Corentin Date: Sun, 3 Aug 2025 17:27:54 +0200 Subject: [PATCH] chore: add msrv + fix clippy lints --- Cargo.toml | 1 + adb_cli/Cargo.toml | 1 + adb_cli/src/handlers/host_commands.rs | 10 +++++----- adb_cli/src/main.rs | 6 +++--- adb_client/Cargo.toml | 1 + adb_client/src/device/adb_message_device.rs | 3 +-- adb_client/src/device/adb_usb_device.rs | 3 +-- adb_client/src/device/commands/install.rs | 2 +- adb_client/src/device/commands/reboot.rs | 2 +- adb_client/src/device/commands/uninstall.rs | 4 ++-- .../src/emulator_device/adb_emulator_device.rs | 3 +-- adb_client/src/models/adb_server_command.rs | 4 ++-- adb_client/src/server/commands/mdns.rs | 2 +- adb_client/src/server_device/commands/list.rs | 2 +- adb_client/src/server_device/commands/recv.rs | 3 +-- adb_client/src/server_device/commands/stat.rs | 3 +-- .../src/server_device/commands/uninstall.rs | 2 +- .../src/transports/tcp_server_transport.rs | 4 ++-- adb_client/src/transports/tcp_transport.rs | 5 ++--- adb_client/src/transports/usb_transport.rs | 16 +++++----------- pyadb_client/Cargo.toml | 1 + 21 files changed, 35 insertions(+), 43 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7b731cc..3414270 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ keywords = ["adb", "android", "tcp", "usb"] license = "MIT" repository = "https://github.com/cocool97/adb_client" version = "2.1.15" +rust-version = "1.85.1" # To build locally when working on a new release [patch.crates-io] diff --git a/adb_cli/Cargo.toml b/adb_cli/Cargo.toml index c2d5748..2885bc9 100644 --- a/adb_cli/Cargo.toml +++ b/adb_cli/Cargo.toml @@ -7,6 +7,7 @@ license.workspace = true name = "adb_cli" readme = "README.md" repository.workspace = true +rust-version.workspace = true version.workspace = true [dependencies] diff --git a/adb_cli/src/handlers/host_commands.rs b/adb_cli/src/handlers/host_commands.rs index 413ee1d..250f465 100644 --- a/adb_cli/src/handlers/host_commands.rs +++ b/adb_cli/src/handlers/host_commands.rs @@ -8,7 +8,7 @@ pub fn handle_host_commands(server_command: ServerCommand) -> Resul match server_command.command { HostCommand::Version => { let version = adb_server.version()?; - log::info!("Android Debug Bridge version {}", version); + log::info!("Android Debug Bridge version {version}"); log::info!("Package version {}-rust", std::env!("CARGO_PKG_VERSION")); } HostCommand::Kill => { @@ -18,18 +18,18 @@ pub fn handle_host_commands(server_command: ServerCommand) -> Resul if long { log::info!("List of devices attached (extended)"); for device in adb_server.devices_long()? { - log::info!("{}", device); + log::info!("{device}"); } } else { log::info!("List of devices attached"); for device in adb_server.devices()? { - log::info!("{}", device); + log::info!("{device}"); } } } HostCommand::TrackDevices => { let callback = |device: DeviceShort| { - log::info!("{}", device); + log::info!("{device}"); Ok(()) }; log::info!("Live list of devices attached"); @@ -65,7 +65,7 @@ pub fn handle_host_commands(server_command: ServerCommand) -> Resul MdnsCommand::Services => { log::info!("List of discovered mdns services"); for service in adb_server.mdns_services()? { - log::info!("{}", service); + log::info!("{service}"); } } }, diff --git a/adb_cli/src/main.rs b/adb_cli/src/main.rs index 14605b2..3ac5af6 100644 --- a/adb_cli/src/main.rs +++ b/adb_cli/src/main.rs @@ -132,10 +132,10 @@ fn main() -> Result<()> { } DeviceCommands::Stat { path } => { let stat_response = device.stat(&path)?; - println!("{}", stat_response); + println!("{stat_response}"); } DeviceCommands::Reboot { reboot_type } => { - log::info!("Reboots device in mode {:?}", reboot_type); + log::info!("Reboots device in mode {reboot_type:?}"); device.reboot(reboot_type.into())? } DeviceCommands::Push { filename, path } => { @@ -152,7 +152,7 @@ fn main() -> Result<()> { device.install(&path)?; } DeviceCommands::Uninstall { package } => { - log::info!("Uninstalling the package {}...", package); + log::info!("Uninstalling the package {package}..."); device.uninstall(&package)?; } DeviceCommands::Framebuffer { path } => { diff --git a/adb_client/Cargo.toml b/adb_client/Cargo.toml index de174c2..590f75a 100644 --- a/adb_client/Cargo.toml +++ b/adb_client/Cargo.toml @@ -7,6 +7,7 @@ license.workspace = true name = "adb_client" readme = "README.md" repository.workspace = true +rust-version.workspace = true version.workspace = true [dependencies] diff --git a/adb_client/src/device/adb_message_device.rs b/adb_client/src/device/adb_message_device.rs index b0974b4..e3036c9 100644 --- a/adb_client/src/device/adb_message_device.rs +++ b/adb_client/src/device/adb_message_device.rs @@ -144,8 +144,7 @@ impl ADBMessageDevice { MessageCommand::Write => return Ok(()), c => { return Err(RustADBError::ADBRequestFailed(format!( - "Wrong command received {}", - c + "Wrong command received {c}" ))); } } diff --git a/adb_client/src/device/adb_usb_device.rs b/adb_client/src/device/adb_usb_device.rs index 0351058..1de4376 100644 --- a/adb_client/src/device/adb_usb_device.rs +++ b/adb_client/src/device/adb_usb_device.rs @@ -56,8 +56,7 @@ pub fn search_adb_devices() -> Result> { (None, _) => Ok(None), (Some(identifiers), None) => Ok(Some(*identifiers)), (Some((vid1, pid1)), Some((vid2, pid2))) => Err(RustADBError::DeviceNotFound(format!( - "Found two Android devices {:04x}:{:04x} and {:04x}:{:04x}", - vid1, pid1, vid2, pid2 + "Found two Android devices {vid1:04x}:{pid1:04x} and {vid2:04x}:{pid2:04x}", ))), } } diff --git a/adb_client/src/device/commands/install.rs b/adb_client/src/device/commands/install.rs index 92d0ba6..3e25b62 100644 --- a/adb_client/src/device/commands/install.rs +++ b/adb_client/src/device/commands/install.rs @@ -14,7 +14,7 @@ impl ADBMessageDevice { let file_size = apk_file.metadata()?.len(); - self.open_session(format!("exec:cmd package 'install' -S {}\0", file_size).as_bytes())?; + self.open_session(format!("exec:cmd package 'install' -S {file_size}\0").as_bytes())?; let transport = self.get_transport().clone(); diff --git a/adb_client/src/device/commands/reboot.rs b/adb_client/src/device/commands/reboot.rs index 9802a85..58438f2 100644 --- a/adb_client/src/device/commands/reboot.rs +++ b/adb_client/src/device/commands/reboot.rs @@ -5,7 +5,7 @@ use crate::{ impl ADBMessageDevice { pub(crate) fn reboot(&mut self, reboot_type: RebootType) -> Result<()> { - self.open_session(format!("reboot:{}\0", reboot_type).as_bytes())?; + self.open_session(format!("reboot:{reboot_type}\0").as_bytes())?; self.get_transport_mut() .read_message() diff --git a/adb_client/src/device/commands/uninstall.rs b/adb_client/src/device/commands/uninstall.rs index c7d4de5..d230446 100644 --- a/adb_client/src/device/commands/uninstall.rs +++ b/adb_client/src/device/commands/uninstall.rs @@ -2,13 +2,13 @@ use crate::{ADBMessageTransport, Result, device::adb_message_device::ADBMessageD impl ADBMessageDevice { pub(crate) fn uninstall(&mut self, package_name: &str) -> Result<()> { - self.open_session(format!("exec:cmd package 'uninstall' {}\0", package_name).as_bytes())?; + self.open_session(format!("exec:cmd package 'uninstall' {package_name}\0").as_bytes())?; let final_status = self.get_transport_mut().read_message()?; match final_status.into_payload().as_slice() { b"Success\n" => { - log::info!("Package {} successfully uninstalled", package_name); + log::info!("Package {package_name} successfully uninstalled"); Ok(()) } d => Err(crate::RustADBError::ADBRequestFailed(String::from_utf8( diff --git a/adb_client/src/emulator_device/adb_emulator_device.rs b/adb_client/src/emulator_device/adb_emulator_device.rs index f5d2881..9c3ec4f 100644 --- a/adb_client/src/emulator_device/adb_emulator_device.rs +++ b/adb_client/src/emulator_device/adb_emulator_device.rs @@ -30,8 +30,7 @@ impl ADBEmulatorDevice { let groups = EMULATOR_REGEX .captures(&identifier) .ok_or(RustADBError::DeviceNotFound(format!( - "Device {} is likely not an emulator", - identifier + "Device {identifier} is likely not an emulator" )))?; let port = groups diff --git a/adb_client/src/models/adb_server_command.rs b/adb_client/src/models/adb_server_command.rs index a36e2ef..8790fbc 100644 --- a/adb_client/src/models/adb_server_command.rs +++ b/adb_client/src/models/adb_server_command.rs @@ -63,8 +63,8 @@ impl Display for AdbServerCommand { AdbServerCommand::Reboot(reboot_type) => { write!(f, "reboot:{reboot_type}") } - AdbServerCommand::Connect(addr) => write!(f, "host:connect:{}", addr), - AdbServerCommand::Disconnect(addr) => write!(f, "host:disconnect:{}", addr), + AdbServerCommand::Connect(addr) => write!(f, "host:connect:{addr}"), + AdbServerCommand::Disconnect(addr) => write!(f, "host:disconnect:{addr}"), AdbServerCommand::Pair(addr, code) => { write!(f, "host:pair:{code}:{addr}") } diff --git a/adb_client/src/server/commands/mdns.rs b/adb_client/src/server/commands/mdns.rs index 0c00352..05a8f28 100644 --- a/adb_client/src/server/commands/mdns.rs +++ b/adb_client/src/server/commands/mdns.rs @@ -32,7 +32,7 @@ impl ADBServer { Ok(service) => { vec_services.push(MDNSServices::try_from(service.as_bytes())?); } - Err(e) => log::error!("{}", e), + Err(e) => log::error!("{e}"), } } diff --git a/adb_client/src/server_device/commands/list.rs b/adb_client/src/server_device/commands/list.rs index 25e2914..54ceb02 100644 --- a/adb_client/src/server_device/commands/list.rs +++ b/adb_client/src/server_device/commands/list.rs @@ -64,7 +64,7 @@ impl ADBServerDevice { "DONE" => { return Ok(()); } - x => log::error!("Got an unknown response {}", x), + x => log::error!("Got an unknown response {x}"), } } } diff --git a/adb_client/src/server_device/commands/recv.rs b/adb_client/src/server_device/commands/recv.rs index 0b344d8..d20fcee 100644 --- a/adb_client/src/server_device/commands/recv.rs +++ b/adb_client/src/server_device/commands/recv.rs @@ -48,8 +48,7 @@ impl Read for ADBRecvCommandReader { ))) } _ => Err(std::io::Error::other(format!( - "Unknown response from device {:#?}", - header + "Unknown response from device {header:#?}" ))), } } else { diff --git a/adb_client/src/server_device/commands/stat.rs b/adb_client/src/server_device/commands/stat.rs index 6d1defa..8e107fa 100644 --- a/adb_client/src/server_device/commands/stat.rs +++ b/adb_client/src/server_device/commands/stat.rs @@ -31,8 +31,7 @@ impl ADBServerDevice { Ok(data.into()) } x => Err(RustADBError::UnknownResponseType(format!( - "Unknown response {}", - x + "Unknown response {x}" ))), } } diff --git a/adb_client/src/server_device/commands/uninstall.rs b/adb_client/src/server_device/commands/uninstall.rs index fa60170..32b8f95 100644 --- a/adb_client/src/server_device/commands/uninstall.rs +++ b/adb_client/src/server_device/commands/uninstall.rs @@ -15,7 +15,7 @@ impl ADBServerDevice { match &data[0..read_amount] { b"Success\n" => { - log::info!("Package {} successfully uninstalled", package_name); + log::info!("Package {package_name} successfully uninstalled"); Ok(()) } d => Err(crate::RustADBError::ADBRequestFailed(String::from_utf8( diff --git a/adb_client/src/transports/tcp_server_transport.rs b/adb_client/src/transports/tcp_server_transport.rs index 259f50f..0b0c29b 100644 --- a/adb_client/src/transports/tcp_server_transport.rs +++ b/adb_client/src/transports/tcp_server_transport.rs @@ -99,13 +99,13 @@ impl TCPServerTransport { } /// Gets the body length from a LittleEndian value - pub(crate) fn get_body_length(&mut self) -> Result { + pub(crate) fn get_body_length(&self) -> Result { let length_buffer = self.read_body_length()?; Ok(LittleEndian::read_u32(&length_buffer)) } /// Read 4 bytes representing body length - fn read_body_length(&mut self) -> Result<[u8; 4]> { + fn read_body_length(&self) -> Result<[u8; 4]> { let mut length_buffer = [0; 4]; self.get_raw_connection()?.read_exact(&mut length_buffer)?; diff --git a/adb_client/src/transports/tcp_transport.rs b/adb_client/src/transports/tcp_transport.rs index 5cb8e45..95e5484 100644 --- a/adb_client/src/transports/tcp_transport.rs +++ b/adb_client/src/transports/tcp_transport.rs @@ -109,7 +109,7 @@ impl TcpTransport { }) } - fn get_current_connection(&mut self) -> Result>> { + fn get_current_connection(&self) -> Result>> { self.current_connection .as_ref() .ok_or(RustADBError::IOError(std::io::Error::new( @@ -175,8 +175,7 @@ impl TcpTransport { Ok(()) } c => Err(RustADBError::ADBRequestFailed(format!( - "Wrong command received {}", - c + "Wrong command received {c}" ))), } } diff --git a/adb_client/src/transports/usb_transport.rs b/adb_client/src/transports/usb_transport.rs index 522c4ca..9f536cb 100644 --- a/adb_client/src/transports/usb_transport.rs +++ b/adb_client/src/transports/usb_transport.rs @@ -40,8 +40,7 @@ impl USBTransport { } Err(RustADBError::DeviceNotFound(format!( - "cannot find USB device with vendor_id={} and product_id={}", - vendor_id, product_id + "cannot find USB device with vendor_id={vendor_id} and product_id={product_id}", ))) } @@ -151,12 +150,7 @@ impl USBTransport { let write_amount = handle.write_bulk(endpoint.address, &data[offset..end], timeout)?; offset += write_amount; - log::trace!( - "wrote chunk of size {} - {}/{}", - write_amount, - offset, - data_len - ) + log::trace!("wrote chunk of size {write_amount} - {offset}/{data_len}",) } if offset % max_packet_size == 0 { @@ -175,11 +169,11 @@ impl ADBTransport for USBTransport { let (read_endpoint, write_endpoint) = self.find_endpoints(&device)?; Self::configure_endpoint(&device, &read_endpoint)?; - log::debug!("got read endpoint: {:?}", read_endpoint); + log::debug!("got read endpoint: {read_endpoint:?}"); self.read_endpoint = Some(read_endpoint); Self::configure_endpoint(&device, &write_endpoint)?; - log::debug!("got write endpoint: {:?}", write_endpoint); + log::debug!("got write endpoint: {write_endpoint:?}"); self.write_endpoint = Some(write_endpoint); self.handle = Some(Arc::new(device)); @@ -197,7 +191,7 @@ impl ADBTransport for USBTransport { let endpoint = self.read_endpoint.as_ref().or(self.write_endpoint.as_ref()); if let Some(endpoint) = &endpoint { match handle.release_interface(endpoint.iface) { - Ok(_) => log::debug!("succesfully released interface"), + Ok(()) => log::debug!("succesfully released interface"), Err(e) => log::error!("error while release interface: {e}"), } } diff --git a/pyadb_client/Cargo.toml b/pyadb_client/Cargo.toml index 6e860cb..cecce2a 100644 --- a/pyadb_client/Cargo.toml +++ b/pyadb_client/Cargo.toml @@ -9,6 +9,7 @@ name = "pyadb_client" readme = "README.md" repository.workspace = true version.workspace = true +rust-version.workspace = true [lib] crate-type = ["cdylib", "rlib"]