Add progress option for mounting personalized

This commit is contained in:
Jackson Coxson
2025-02-06 15:30:34 -07:00
parent dee313eb64
commit 5ccfe2d46a
3 changed files with 31 additions and 5 deletions

2
Cargo.lock generated
View File

@@ -874,7 +874,7 @@ dependencies = [
[[package]] [[package]]
name = "idevice" name = "idevice"
version = "0.1.18" version = "0.1.19"
dependencies = [ dependencies = [
"async-recursion", "async-recursion",
"base64", "base64",

View File

@@ -2,7 +2,7 @@
name = "idevice" name = "idevice"
description = "A Rust library to interact with services on iOS devices." description = "A Rust library to interact with services on iOS devices."
authors = ["Jackson Coxson"] authors = ["Jackson Coxson"]
version = "0.1.18" version = "0.1.19"
edition = "2021" edition = "2021"
license = "MIT" license = "MIT"
documentation = "https://docs.rs/idevice" documentation = "https://docs.rs/idevice"

View File

@@ -311,8 +311,6 @@ impl ImageMounter {
Ok(()) Ok(())
} }
/// Calling this has the potential of closing the socket,
/// so a provider is required for this abstraction.
pub async fn mount_personalized( pub async fn mount_personalized(
&mut self, &mut self,
provider: &dyn crate::provider::IdeviceProvider, provider: &dyn crate::provider::IdeviceProvider,
@@ -322,6 +320,34 @@ impl ImageMounter {
info_plist: Option<plist::Value>, info_plist: Option<plist::Value>,
unique_chip_id: u64, unique_chip_id: u64,
) -> Result<(), IdeviceError> { ) -> Result<(), IdeviceError> {
self.mount_personalized_with_callback(
provider,
image,
trust_cache,
build_manifest,
info_plist,
unique_chip_id,
|_| async {},
)
.await
}
/// Calling this has the potential of closing the socket,
/// so a provider is required for this abstraction.
#[allow(clippy::too_many_arguments)] // literally nobody asked
pub async fn mount_personalized_with_callback<Fut>(
&mut self,
provider: &dyn crate::provider::IdeviceProvider,
image: Vec<u8>,
trust_cache: Vec<u8>,
build_manifest: &[u8],
info_plist: Option<plist::Value>,
unique_chip_id: u64,
callback: impl Fn((usize, usize)) -> Fut,
) -> Result<(), IdeviceError>
where
Fut: std::future::Future<Output = ()>,
{
// Try to fetch personalization manifest // Try to fetch personalization manifest
let mut hasher = Sha384::new(); let mut hasher = Sha384::new();
hasher.update(&image); hasher.update(&image);
@@ -345,7 +371,7 @@ impl ImageMounter {
}; };
debug!("Uploading imaage"); debug!("Uploading imaage");
self.upload_image("Personalized", &image, manifest.clone()) self.upload_image_with_progress("Personalized", &image, manifest.clone(), callback)
.await?; .await?;
debug!("Mounting image"); debug!("Mounting image");