mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 14:36:16 +01:00
Use option<&str> instead of owned option string
This commit is contained in:
@@ -98,10 +98,10 @@ impl InstallationProxyClient {
|
||||
/// ```
|
||||
pub async fn get_apps(
|
||||
&mut self,
|
||||
application_type: Option<String>,
|
||||
application_type: Option<&str>,
|
||||
bundle_identifiers: Option<Vec<String>>,
|
||||
) -> Result<HashMap<String, plist::Value>, IdeviceError> {
|
||||
let application_type = application_type.unwrap_or("Any".to_string());
|
||||
let application_type = application_type.unwrap_or("Any");
|
||||
let mut options = plist::Dictionary::new();
|
||||
if let Some(ids) = bundle_identifiers {
|
||||
let ids = ids
|
||||
|
||||
@@ -86,16 +86,16 @@ impl LockdownClient {
|
||||
/// ```
|
||||
pub async fn get_value(
|
||||
&mut self,
|
||||
key: impl Into<String>,
|
||||
domain: Option<String>,
|
||||
key: Option<&str>,
|
||||
domain: Option<&str>,
|
||||
) -> Result<Value, IdeviceError> {
|
||||
let key = key.into();
|
||||
|
||||
let mut request = plist::Dictionary::new();
|
||||
request.insert("Label".into(), self.idevice.label.clone().into());
|
||||
request.insert("Request".into(), "GetValue".into());
|
||||
request.insert("Key".into(), key.into());
|
||||
|
||||
if let Some(key) = key {
|
||||
request.insert("Key".into(), key.into());
|
||||
}
|
||||
if let Some(domain) = domain {
|
||||
request.insert("Domain".into(), domain.into());
|
||||
}
|
||||
@@ -110,43 +110,6 @@ impl LockdownClient {
|
||||
}
|
||||
}
|
||||
|
||||
/// Retrieves all available values from the device
|
||||
///
|
||||
/// # Returns
|
||||
/// A dictionary containing all device values
|
||||
///
|
||||
/// # Errors
|
||||
/// Returns `IdeviceError` if:
|
||||
/// - Communication fails
|
||||
/// - The response is malformed
|
||||
///
|
||||
/// # Example
|
||||
/// ```rust
|
||||
/// let all_values = client.get_all_values().await?;
|
||||
/// for (key, value) in all_values {
|
||||
/// println!("{}: {:?}", key, value);
|
||||
/// }
|
||||
/// ```
|
||||
pub async fn get_all_values(
|
||||
&mut self,
|
||||
domain: Option<String>,
|
||||
) -> Result<plist::Dictionary, IdeviceError> {
|
||||
let mut request = plist::Dictionary::new();
|
||||
request.insert("Label".into(), self.idevice.label.clone().into());
|
||||
request.insert("Request".into(), "GetValue".into());
|
||||
if let Some(domain) = domain {
|
||||
request.insert("Domain".into(), domain.into());
|
||||
}
|
||||
|
||||
let message = plist::to_value(&request)?;
|
||||
self.idevice.send_plist(message).await?;
|
||||
let message: plist::Dictionary = self.idevice.read_plist().await?;
|
||||
match message.get("Value") {
|
||||
Some(m) => Ok(plist::from_value(m)?),
|
||||
None => Err(IdeviceError::UnexpectedResponse),
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets a value on the device
|
||||
///
|
||||
/// # Arguments
|
||||
@@ -167,7 +130,7 @@ impl LockdownClient {
|
||||
&mut self,
|
||||
key: impl Into<String>,
|
||||
value: Value,
|
||||
domain: Option<String>,
|
||||
domain: Option<&str>,
|
||||
) -> Result<(), IdeviceError> {
|
||||
let key = key.into();
|
||||
|
||||
@@ -321,7 +284,7 @@ impl LockdownClient {
|
||||
let host_id = host_id.into();
|
||||
let system_buid = system_buid.into();
|
||||
|
||||
let pub_key = self.get_value("DevicePublicKey", None).await?;
|
||||
let pub_key = self.get_value(Some("DevicePublicKey"), None).await?;
|
||||
let pub_key = match pub_key.as_data().map(|x| x.to_vec()) {
|
||||
Some(p) => p,
|
||||
None => {
|
||||
@@ -330,7 +293,7 @@ impl LockdownClient {
|
||||
}
|
||||
};
|
||||
|
||||
let wifi_mac = self.get_value("WiFiAddress", None).await?;
|
||||
let wifi_mac = self.get_value(Some("WiFiAddress"), None).await?;
|
||||
let wifi_mac = match wifi_mac.as_string() {
|
||||
Some(w) => w,
|
||||
None => {
|
||||
|
||||
@@ -113,7 +113,7 @@ impl ImageMounter {
|
||||
/// Returns `IdeviceError::NotFound` if image doesn't exist
|
||||
pub async fn lookup_image(
|
||||
&mut self,
|
||||
image_type: impl Into<String>,
|
||||
image_type: impl Into<&str>,
|
||||
) -> Result<Vec<u8>, IdeviceError> {
|
||||
let image_type = image_type.into();
|
||||
let mut req = plist::Dictionary::new();
|
||||
@@ -370,7 +370,7 @@ impl ImageMounter {
|
||||
/// Returns `IdeviceError` if query fails
|
||||
pub async fn query_nonce(
|
||||
&mut self,
|
||||
personalized_image_type: Option<String>,
|
||||
personalized_image_type: Option<&str>,
|
||||
) -> Result<Vec<u8>, IdeviceError> {
|
||||
let mut req = plist::Dictionary::new();
|
||||
req.insert("Command".into(), "QueryNonce".into());
|
||||
@@ -400,7 +400,7 @@ impl ImageMounter {
|
||||
/// Returns `IdeviceError` if query fails
|
||||
pub async fn query_personalization_identifiers(
|
||||
&mut self,
|
||||
image_type: Option<String>,
|
||||
image_type: Option<&str>,
|
||||
) -> Result<plist::Dictionary, IdeviceError> {
|
||||
let mut req = plist::Dictionary::new();
|
||||
req.insert("Command".into(), "QueryPersonalizationIdentifiers".into());
|
||||
@@ -626,10 +626,7 @@ impl ImageMounter {
|
||||
request.insert("ApECID", unique_chip_id);
|
||||
request.insert(
|
||||
"ApNonce",
|
||||
plist::Value::Data(
|
||||
self.query_nonce(Some("DeveloperDiskImage".to_string()))
|
||||
.await?,
|
||||
),
|
||||
plist::Value::Data(self.query_nonce(Some("DeveloperDiskImage")).await?),
|
||||
);
|
||||
request.insert("ApProductionMode", true);
|
||||
request.insert("ApSecurityDomain", 1);
|
||||
|
||||
Reference in New Issue
Block a user