chore: clippy lints + v2.1.19
This commit is contained in:
@@ -9,7 +9,7 @@ homepage = "https://github.com/cocool97/adb_client"
|
||||
keywords = ["adb", "android", "tcp", "usb"]
|
||||
license = "MIT"
|
||||
repository = "https://github.com/cocool97/adb_client"
|
||||
version = "2.1.18"
|
||||
version = "2.1.19"
|
||||
rust-version = "1.91.0"
|
||||
|
||||
# To build locally when working on a new release
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# adb_client
|
||||
# `adb_client`
|
||||
|
||||
[](./LICENSE-MIT)
|
||||
[](https://docs.rs/adb_client)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::io::Write;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::path::Path;
|
||||
use std::{io::Read, net::SocketAddr};
|
||||
|
||||
use super::adb_message_device::ADBMessageDevice;
|
||||
@@ -22,16 +22,16 @@ impl ADBTcpDevice {
|
||||
}
|
||||
|
||||
/// Instantiate a new [`ADBTcpDevice`] using a custom private key path
|
||||
pub fn new_with_custom_private_key(
|
||||
pub fn new_with_custom_private_key<P: AsRef<Path>>(
|
||||
address: SocketAddr,
|
||||
private_key_path: PathBuf,
|
||||
private_key_path: P,
|
||||
) -> Result<Self> {
|
||||
let private_key = if let Some(private_key) = read_adb_private_key(&private_key_path)? {
|
||||
private_key
|
||||
} else {
|
||||
log::warn!(
|
||||
"No private key found at path {}. Using a temporary random one.",
|
||||
private_key_path.display()
|
||||
private_key_path.as_ref().display()
|
||||
);
|
||||
ADBRsaKey::new_random()?
|
||||
};
|
||||
|
||||
@@ -110,12 +110,12 @@ impl ADBUSBDevice {
|
||||
}
|
||||
|
||||
/// Instantiate a new [`ADBUSBDevice`] using a custom private key path
|
||||
pub fn new_with_custom_private_key(
|
||||
pub fn new_with_custom_private_key<P: AsRef<Path>>(
|
||||
vendor_id: u16,
|
||||
product_id: u16,
|
||||
private_key_path: PathBuf,
|
||||
private_key_path: P,
|
||||
) -> Result<Self> {
|
||||
Self::new_from_transport_inner(USBTransport::new(vendor_id, product_id)?, &private_key_path)
|
||||
Self::new_from_transport_inner(USBTransport::new(vendor_id, product_id)?, private_key_path)
|
||||
}
|
||||
|
||||
/// Instantiate a new [`ADBUSBDevice`] from a [`USBTransport`] and an optional private key path.
|
||||
@@ -131,16 +131,16 @@ impl ADBUSBDevice {
|
||||
Self::new_from_transport_inner(transport, &private_key_path)
|
||||
}
|
||||
|
||||
fn new_from_transport_inner(
|
||||
fn new_from_transport_inner<P: AsRef<Path>>(
|
||||
transport: USBTransport,
|
||||
private_key_path: &PathBuf,
|
||||
private_key_path: P,
|
||||
) -> Result<Self> {
|
||||
let private_key = if let Some(private_key) = read_adb_private_key(private_key_path)? {
|
||||
let private_key = if let Some(private_key) = read_adb_private_key(&private_key_path)? {
|
||||
private_key
|
||||
} else {
|
||||
log::warn!(
|
||||
"No private key found at path {}. Using a temporary random one.",
|
||||
private_key_path.display()
|
||||
private_key_path.as_ref().display()
|
||||
);
|
||||
ADBRsaKey::new_random()?
|
||||
};
|
||||
|
||||
@@ -147,7 +147,7 @@ impl<T: ADBMessageTransport> ADBMessageDevice<T> {
|
||||
let name = String::from_utf8(name_buf)?;
|
||||
|
||||
// First 9 bits are the file permissions
|
||||
let permissions = mode & 0b111111111;
|
||||
let permissions = mode & 0b1_1111_1111;
|
||||
// Bits 14 to 16 are the file type
|
||||
let item_type = match (mode >> 13) & 0b111 {
|
||||
0b010 => ADBListItemType::Directory,
|
||||
|
||||
@@ -3,6 +3,6 @@ use crate::{ADBEmulatorDevice, Result, emulator_device::ADBEmulatorCommand};
|
||||
impl ADBEmulatorDevice {
|
||||
/// Send a SMS to this emulator with given content with given phone number
|
||||
pub fn rotate(&mut self) -> Result<()> {
|
||||
self.connect()?.send_command(ADBEmulatorCommand::Rotate)
|
||||
self.connect()?.send_command(&ADBEmulatorCommand::Rotate)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::{ADBEmulatorDevice, Result, emulator_device::ADBEmulatorCommand};
|
||||
impl ADBEmulatorDevice {
|
||||
/// Send a SMS to this emulator with given content with given phone number
|
||||
pub fn send_sms(&mut self, phone_number: &str, content: &str) -> Result<()> {
|
||||
self.connect()?.send_command(ADBEmulatorCommand::Sms(
|
||||
self.connect()?.send_command(&ADBEmulatorCommand::Sms(
|
||||
phone_number.to_string(),
|
||||
content.to_string(),
|
||||
))
|
||||
|
||||
@@ -16,6 +16,7 @@ pub struct AdbVersion {
|
||||
|
||||
impl AdbVersion {
|
||||
/// Instantiates a new [`AdbVersion`].
|
||||
#[must_use]
|
||||
pub fn new(minor: u32, revision: u32) -> Self {
|
||||
Self {
|
||||
major: 1,
|
||||
|
||||
@@ -18,7 +18,7 @@ impl ADBServerDevice {
|
||||
self.transport.send_adb_request(AdbServerCommand::Sync)?;
|
||||
|
||||
// Send a list command
|
||||
self.transport.send_sync_request(SyncCommand::List)?;
|
||||
self.transport.send_sync_request(&SyncCommand::List)?;
|
||||
|
||||
self.handle_list_command(path)
|
||||
}
|
||||
@@ -58,7 +58,7 @@ impl ADBServerDevice {
|
||||
let name = String::from_utf8(name_buf)?;
|
||||
|
||||
// First 9 bits are the file permissions
|
||||
let permissions = mode & 0b111111111;
|
||||
let permissions = mode & 0b1_1111_1111;
|
||||
// Bits 14 to 16 are the file type
|
||||
let item_type = match (mode >> 13) & 0b111 {
|
||||
0b010 => ADBListItemType::Directory,
|
||||
|
||||
@@ -72,7 +72,7 @@ impl ADBServerDevice {
|
||||
self.transport.send_adb_request(AdbServerCommand::Sync)?;
|
||||
|
||||
// Send a recv command
|
||||
self.transport.send_sync_request(SyncCommand::Recv)?;
|
||||
self.transport.send_sync_request(&SyncCommand::Recv)?;
|
||||
|
||||
self.handle_recv_command(path, stream)
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ impl ADBServerDevice {
|
||||
self.transport.send_adb_request(AdbServerCommand::Sync)?;
|
||||
|
||||
// Send a send command
|
||||
self.transport.send_sync_request(SyncCommand::Send)?;
|
||||
self.transport.send_sync_request(&SyncCommand::Send)?;
|
||||
|
||||
self.handle_send_command(stream, path)
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ impl ADBServerDevice {
|
||||
self.transport.send_adb_request(AdbServerCommand::Sync)?;
|
||||
|
||||
// Send a "Stat" command
|
||||
self.transport.send_sync_request(SyncCommand::Stat)?;
|
||||
self.transport.send_sync_request(&SyncCommand::Stat)?;
|
||||
|
||||
self.handle_stat_command(path)
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ pub struct TCPEmulatorTransport {
|
||||
|
||||
impl TCPEmulatorTransport {
|
||||
/// Instantiates a new instance of [`TCPEmulatorTransport`]
|
||||
#[must_use]
|
||||
pub fn new(socket_addr: SocketAddrV4) -> Self {
|
||||
Self {
|
||||
socket_addr,
|
||||
@@ -48,11 +49,11 @@ impl TCPEmulatorTransport {
|
||||
/// Send an authenticate request to this emulator
|
||||
pub fn authenticate(&mut self) -> Result<()> {
|
||||
let token = self.get_authentication_token()?;
|
||||
self.send_command(ADBEmulatorCommand::Authenticate(token))
|
||||
self.send_command(&ADBEmulatorCommand::Authenticate(token))
|
||||
}
|
||||
|
||||
/// Send an [`ADBEmulatorCommand`] to this emulator
|
||||
pub(crate) fn send_command(&mut self, command: ADBEmulatorCommand) -> Result<()> {
|
||||
pub(crate) fn send_command(&mut self, command: &ADBEmulatorCommand) -> Result<()> {
|
||||
let mut connection = self.get_raw_connection()?;
|
||||
|
||||
// Send command
|
||||
|
||||
@@ -34,6 +34,7 @@ impl TCPServerTransport {
|
||||
}
|
||||
|
||||
/// Instantiate a new instance of [`TCPServerTransport`] using given address, or default if not specified.
|
||||
#[must_use]
|
||||
pub fn new_or_default(socket_addr: Option<SocketAddrV4>) -> Self {
|
||||
match socket_addr {
|
||||
Some(s) => Self::new(s),
|
||||
@@ -42,6 +43,7 @@ impl TCPServerTransport {
|
||||
}
|
||||
|
||||
/// Get underlying [`SocketAddrV4`]
|
||||
#[must_use]
|
||||
pub fn get_socketaddr(&self) -> SocketAddrV4 {
|
||||
self.socket_addr
|
||||
}
|
||||
@@ -90,7 +92,7 @@ impl TCPServerTransport {
|
||||
}
|
||||
|
||||
/// Send the given [`SyncCommand`] to ADB server, and checks that the request has been taken in consideration.
|
||||
pub(crate) fn send_sync_request(&mut self, command: SyncCommand) -> Result<()> {
|
||||
pub(crate) fn send_sync_request(&mut self, command: &SyncCommand) -> Result<()> {
|
||||
// First 4 bytes are the name of the command we want to send
|
||||
// (e.g. "SEND", "RECV", "STAT", "LIST")
|
||||
Ok(self
|
||||
|
||||
@@ -21,6 +21,7 @@ impl PyADBUSBDevice {
|
||||
}
|
||||
|
||||
/// Run shell commands on device and return the output (stdout + stderr merged)
|
||||
#[expect(clippy::needless_pass_by_value)]
|
||||
pub fn shell_command(&mut self, commands: Vec<String>) -> Result<Vec<u8>> {
|
||||
let mut output = Vec::new();
|
||||
let commands: Vec<&str> = commands.iter().map(|x| &**x).collect();
|
||||
@@ -41,6 +42,7 @@ impl PyADBUSBDevice {
|
||||
}
|
||||
|
||||
/// Install a package installed on the device
|
||||
#[expect(clippy::needless_pass_by_value)]
|
||||
pub fn install(&mut self, apk_path: PathBuf) -> Result<()> {
|
||||
Ok(self.0.install(&apk_path)?)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user