Fix cargo clippy warnings

This commit is contained in:
Jackson Coxson
2025-08-12 08:19:31 -06:00
parent 0e4f12f0bf
commit 5ee385c95c
14 changed files with 59 additions and 59 deletions

View File

@@ -329,10 +329,10 @@ pub unsafe extern "C" fn app_service_launch_app(
if !argv.is_null() && argc > 0 { if !argv.is_null() && argc > 0 {
let argv_slice = unsafe { std::slice::from_raw_parts(argv, argc) }; let argv_slice = unsafe { std::slice::from_raw_parts(argv, argc) };
for &arg in argv_slice { for &arg in argv_slice {
if !arg.is_null() { if !arg.is_null()
if let Ok(arg_str) = unsafe { CStr::from_ptr(arg) }.to_str() { && let Ok(arg_str) = unsafe { CStr::from_ptr(arg) }.to_str()
args.push(arg_str); {
} args.push(arg_str);
} }
} }
} }

View File

@@ -105,10 +105,10 @@ pub unsafe extern "C" fn process_control_launch_app(
for &env_var in env_vars_slice { for &env_var in env_vars_slice {
if !env_var.is_null() { if !env_var.is_null() {
let env_var = unsafe { CStr::from_ptr(env_var) }; let env_var = unsafe { CStr::from_ptr(env_var) };
if let Ok(env_var) = env_var.to_str() { if let Ok(env_var) = env_var.to_str()
if let Some((key, value)) = env_var.split_once('=') { && let Some((key, value)) = env_var.split_once('=')
env_dict.insert(key.to_string(), Value::String(value.to_string())); {
} env_dict.insert(key.to_string(), Value::String(value.to_string()));
} }
} }
} }

View File

@@ -25,7 +25,7 @@ pub use services::*;
#[cfg(feature = "xpc")] #[cfg(feature = "xpc")]
pub use xpc::RemoteXpcClient; pub use xpc::RemoteXpcClient;
use log::{debug, error, trace, warn}; use log::{debug, error, trace};
use provider::{IdeviceProvider, RsdProvider}; use provider::{IdeviceProvider, RsdProvider};
use rustls::{crypto::CryptoProvider, pki_types::ServerName}; use rustls::{crypto::CryptoProvider, pki_types::ServerName};
use std::{ use std::{
@@ -443,7 +443,7 @@ impl Idevice {
// My sanity while debugging the workspace crates are more important. // My sanity while debugging the workspace crates are more important.
debug!("Using ring crypto backend, because both were passed"); debug!("Using ring crypto backend, because both were passed");
warn!("Both ring && aws-lc are selected as idevice crypto backends!"); log::warn!("Both ring && aws-lc are selected as idevice crypto backends!");
rustls::crypto::ring::default_provider() rustls::crypto::ring::default_provider()
} }
}; };

View File

@@ -11,7 +11,7 @@ use log::warn;
use opcode::{AfcFopenMode, AfcOpcode}; use opcode::{AfcFopenMode, AfcOpcode};
use packet::{AfcPacket, AfcPacketHeader}; use packet::{AfcPacket, AfcPacketHeader};
use crate::{obf, Idevice, IdeviceError, IdeviceService}; use crate::{Idevice, IdeviceError, IdeviceService, obf};
pub mod errors; pub mod errors;
pub mod file; pub mod file;
@@ -376,11 +376,11 @@ impl AfcClient {
/// ///
/// # Returns /// # Returns
/// A `FileDescriptor` struct for the opened file /// A `FileDescriptor` struct for the opened file
pub async fn open( pub async fn open<'f>(
&mut self, &'f mut self,
path: impl Into<String>, path: impl Into<String>,
mode: AfcFopenMode, mode: AfcFopenMode,
) -> Result<FileDescriptor, IdeviceError> { ) -> Result<FileDescriptor<'f>, IdeviceError> {
let path = path.into(); let path = path.into();
let mut header_payload = (mode as u64).to_le_bytes().to_vec(); let mut header_payload = (mode as u64).to_le_bytes().to_vec();
header_payload.extend(path.as_bytes()); header_payload.extend(path.as_bytes());

View File

@@ -3,7 +3,7 @@
use log::warn; use log::warn;
use serde::Deserialize; use serde::Deserialize;
use crate::{obf, IdeviceError, ReadWrite, RsdService}; use crate::{IdeviceError, ReadWrite, RsdService, obf};
use super::CoreDeviceServiceClient; use super::CoreDeviceServiceClient;
@@ -128,7 +128,7 @@ pub struct IconUuid {
pub classes: Vec<String>, pub classes: Vec<String>,
} }
impl<'a, R: ReadWrite + 'a> AppServiceClient<R> { impl<R: ReadWrite> AppServiceClient<R> {
pub async fn new(stream: R) -> Result<Self, IdeviceError> { pub async fn new(stream: R) -> Result<Self, IdeviceError> {
Ok(Self { Ok(Self {
inner: CoreDeviceServiceClient::new(stream).await?, inner: CoreDeviceServiceClient::new(stream).await?,

View File

@@ -4,8 +4,8 @@
use log::warn; use log::warn;
use crate::{ use crate::{
xpc::{self, XPCObject},
IdeviceError, ReadWrite, RemoteXpcClient, IdeviceError, ReadWrite, RemoteXpcClient,
xpc::{self, XPCObject},
}; };
mod app_service; mod app_service;
@@ -17,7 +17,7 @@ pub struct CoreDeviceServiceClient<R: ReadWrite> {
inner: RemoteXpcClient<R>, inner: RemoteXpcClient<R>,
} }
impl<'a, R: ReadWrite + 'a> CoreDeviceServiceClient<R> { impl<R: ReadWrite> CoreDeviceServiceClient<R> {
pub async fn new(inner: R) -> Result<Self, IdeviceError> { pub async fn new(inner: R) -> Result<Self, IdeviceError> {
let mut client = RemoteXpcClient::new(inner).await?; let mut client = RemoteXpcClient::new(inner).await?;
client.do_handshake().await?; client.do_handshake().await?;

View File

@@ -55,8 +55,8 @@ use log::{debug, warn};
use tokio::io::AsyncWriteExt; use tokio::io::AsyncWriteExt;
use crate::{ use crate::{
dvt::message::{Aux, AuxValue, Message, MessageHeader, PayloadHeader},
IdeviceError, ReadWrite, IdeviceError, ReadWrite,
dvt::message::{Aux, AuxValue, Message, MessageHeader, PayloadHeader},
}; };
/// Message type identifier for instruments protocol /// Message type identifier for instruments protocol
@@ -112,7 +112,7 @@ impl<R: ReadWrite> RemoteServerClient<R> {
} }
/// Returns a handle to the root channel (channel 0) /// Returns a handle to the root channel (channel 0)
pub fn root_channel(&mut self) -> Channel<R> { pub fn root_channel<'c>(&'c mut self) -> Channel<'c, R> {
Channel { Channel {
client: self, client: self,
channel: 0, channel: 0,
@@ -131,10 +131,10 @@ impl<R: ReadWrite> RemoteServerClient<R> {
/// # Errors /// # Errors
/// * `IdeviceError::UnexpectedResponse` if server responds with unexpected data /// * `IdeviceError::UnexpectedResponse` if server responds with unexpected data
/// * Other IO or serialization errors /// * Other IO or serialization errors
pub async fn make_channel( pub async fn make_channel<'c>(
&mut self, &'c mut self,
identifier: impl Into<String>, identifier: impl Into<String>,
) -> Result<Channel<R>, IdeviceError> { ) -> Result<Channel<'c, R>, IdeviceError> {
let code = self.new_channel; let code = self.new_channel;
self.new_channel += 1; self.new_channel += 1;
@@ -164,7 +164,7 @@ impl<R: ReadWrite> RemoteServerClient<R> {
self.build_channel(code) self.build_channel(code)
} }
fn build_channel(&mut self, code: u32) -> Result<Channel<R>, IdeviceError> { fn build_channel<'c>(&'c mut self, code: u32) -> Result<Channel<'c, R>, IdeviceError> {
Ok(Channel { Ok(Channel {
client: self, client: self,
channel: code, channel: code,

View File

@@ -8,7 +8,7 @@ use std::collections::HashMap;
use log::warn; use log::warn;
use plist::Dictionary; use plist::Dictionary;
use crate::{obf, Idevice, IdeviceError, IdeviceService}; use crate::{Idevice, IdeviceError, IdeviceService, obf};
/// Client for interacting with the iOS installation proxy service /// Client for interacting with the iOS installation proxy service
/// ///
@@ -376,10 +376,10 @@ impl InstallationProxyClient {
break; break;
} }
if let Some(status) = res.get("Status").and_then(|x| x.as_string()) { if let Some(status) = res.get("Status").and_then(|x| x.as_string())
if status == "Complete" { && status == "Complete"
break; {
} break;
} }
} }
Ok(values) Ok(values)
@@ -424,10 +424,10 @@ impl InstallationProxyClient {
callback((c, state.clone())).await; callback((c, state.clone())).await;
} }
if let Some(c) = res.remove("Status").and_then(|x| x.into_string()) { if let Some(c) = res.remove("Status").and_then(|x| x.into_string())
if c == "Complete" { && c == "Complete"
break; {
} break;
} }
} }
Ok(()) Ok(())

View File

@@ -9,7 +9,7 @@
use log::debug; use log::debug;
use crate::{obf, Idevice, IdeviceError, IdeviceService}; use crate::{Idevice, IdeviceError, IdeviceService, obf};
use sha2::{Digest, Sha384}; use sha2::{Digest, Sha384};
#[cfg(feature = "tss")] #[cfg(feature = "tss")]
@@ -710,10 +710,9 @@ impl ImageMounter {
.and_then(|l| l.as_dictionary()) .and_then(|l| l.as_dictionary())
.and_then(|l| l.get("Info")) .and_then(|l| l.get("Info"))
.and_then(|i| i.as_dictionary()) .and_then(|i| i.as_dictionary())
&& let Some(plist::Value::Array(rules)) = info.get("RestoreRequestRules")
{ {
if let Some(plist::Value::Array(rules)) = info.get("RestoreRequestRules") { crate::tss::apply_restore_request_rules(&mut tss_entry, &parameters, rules);
crate::tss::apply_restore_request_rules(&mut tss_entry, &parameters, rules);
}
} }
if manifest_item.get("Digest").is_none() { if manifest_item.get("Digest").is_none() {

View File

@@ -8,7 +8,7 @@
use log::{debug, warn}; use log::{debug, warn};
use plist::Value; use plist::Value;
use crate::{util::plist_to_xml_bytes, IdeviceError}; use crate::{IdeviceError, util::plist_to_xml_bytes};
/// TSS client version string sent in requests /// TSS client version string sent in requests
const TSS_CLIENT_VERSION_STRING: &str = "libauthinstall-1033.0.2"; const TSS_CLIENT_VERSION_STRING: &str = "libauthinstall-1033.0.2";
@@ -172,15 +172,15 @@ pub fn apply_restore_request_rules(
for (key, value) in actions { for (key, value) in actions {
// Skip special values (255 typically means "ignore") // Skip special values (255 typically means "ignore")
if let Some(i) = value.as_unsigned_integer() { if let Some(i) = value.as_unsigned_integer()
if i == 255 { && i == 255
continue; {
} continue;
} }
if let Some(i) = value.as_signed_integer() { if let Some(i) = value.as_signed_integer()
if i == 255 { && i == 255
continue; {
} continue;
} }
input.remove(key); // Explicitly remove before inserting input.remove(key); // Explicitly remove before inserting

View File

@@ -17,7 +17,7 @@ pub struct Http2Client<R: ReadWrite> {
cache: HashMap<u32, VecDeque<Vec<u8>>>, cache: HashMap<u32, VecDeque<Vec<u8>>>,
} }
impl<'a, R: ReadWrite + 'a> Http2Client<R> { impl<R: ReadWrite> Http2Client<R> {
/// Writes the magic and inits the caches /// Writes the magic and inits the caches
pub async fn new(mut inner: R) -> Result<Self, IdeviceError> { pub async fn new(mut inner: R) -> Result<Self, IdeviceError> {
inner.write_all(HTTP2_MAGIC).await?; inner.write_all(HTTP2_MAGIC).await?;

View File

@@ -17,15 +17,14 @@ const REPLY_CHANNEL: u32 = 3;
pub struct RemoteXpcClient<R: ReadWrite> { pub struct RemoteXpcClient<R: ReadWrite> {
h2_client: http2::Http2Client<R>, h2_client: http2::Http2Client<R>,
root_id: u64, root_id: u64,
reply_id: u64, // reply_id: u64 // maybe not used?
} }
impl<'a, R: ReadWrite + 'a> RemoteXpcClient<R> { impl<R: ReadWrite> RemoteXpcClient<R> {
pub async fn new(socket: R) -> Result<Self, IdeviceError> { pub async fn new(socket: R) -> Result<Self, IdeviceError> {
Ok(Self { Ok(Self {
h2_client: http2::Http2Client::new(socket).await?, h2_client: http2::Http2Client::new(socket).await?,
root_id: 1, root_id: 1,
reply_id: 1,
}) })
} }
@@ -86,11 +85,11 @@ impl<'a, R: ReadWrite + 'a> RemoteXpcClient<R> {
match msg.message { match msg.message {
Some(msg) => { Some(msg) => {
if let Some(d) = msg.as_dictionary() { if let Some(d) = msg.as_dictionary()
if d.is_empty() { && d.is_empty()
msg_buffer.clear(); {
continue; msg_buffer.clear();
} continue;
} }
break Ok(msg.to_plist()); break Ok(msg.to_plist());
} }

View File

@@ -3,7 +3,7 @@ name = "idevice-tools"
description = "Rust binary tools to interact with services on iOS devices." description = "Rust binary tools to interact with services on iOS devices."
authors = ["Jackson Coxson"] authors = ["Jackson Coxson"]
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2024"
license = "MIT" license = "MIT"
documentation = "https://docs.rs/idevice" documentation = "https://docs.rs/idevice"
repository = "https://github.com/jkcoxson/idevice" repository = "https://github.com/jkcoxson/idevice"

View File

@@ -38,14 +38,16 @@ pub async fn get_provider(
} }
}; };
Box::new(dev.to_provider(UsbmuxdAddr::from_env_var().unwrap(), label)) Box::new(dev.to_provider(UsbmuxdAddr::from_env_var().unwrap(), label))
} else if host.is_some() && pairing_file.is_some() { } else if let Some(host) = host
let host = match IpAddr::from_str(host.unwrap()) { && let Some(pairing_file) = pairing_file
{
let host = match IpAddr::from_str(host) {
Ok(h) => h, Ok(h) => h,
Err(e) => { Err(e) => {
return Err(format!("Invalid host: {e:?}")); return Err(format!("Invalid host: {e:?}"));
} }
}; };
let pairing_file = match PairingFile::read_from_file(pairing_file.unwrap()) { let pairing_file = match PairingFile::read_from_file(pairing_file) {
Ok(p) => p, Ok(p) => p,
Err(e) => { Err(e) => {
return Err(format!("Unable to read pairing file: {e:?}")); return Err(format!("Unable to read pairing file: {e:?}"));