mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 14:36:16 +01:00
Plist macro creation in lib.rs
This commit is contained in:
@@ -174,11 +174,12 @@ impl Idevice {
|
|||||||
/// # Errors
|
/// # Errors
|
||||||
/// Returns `IdeviceError` if communication fails or response is invalid
|
/// Returns `IdeviceError` if communication fails or response is invalid
|
||||||
pub async fn get_type(&mut self) -> Result<String, IdeviceError> {
|
pub async fn get_type(&mut self) -> Result<String, IdeviceError> {
|
||||||
let mut req = plist::Dictionary::new();
|
let req = crate::plist!({
|
||||||
req.insert("Label".into(), self.label.clone().into());
|
"Label": self.label.clone(),
|
||||||
req.insert("Request".into(), "QueryType".into());
|
"Request": "QueryType",
|
||||||
let message = plist::to_value(&req)?;
|
});
|
||||||
self.send_plist(message).await?;
|
self.send_plist(req).await?;
|
||||||
|
|
||||||
let message: plist::Dictionary = self.read_plist().await?;
|
let message: plist::Dictionary = self.read_plist().await?;
|
||||||
match message.get("Type") {
|
match message.get("Type") {
|
||||||
Some(m) => Ok(plist::from_value(m)?),
|
Some(m) => Ok(plist::from_value(m)?),
|
||||||
@@ -193,11 +194,13 @@ impl Idevice {
|
|||||||
/// # Errors
|
/// # Errors
|
||||||
/// Returns `IdeviceError` if the protocol sequence isn't followed correctly
|
/// Returns `IdeviceError` if the protocol sequence isn't followed correctly
|
||||||
pub async fn rsd_checkin(&mut self) -> Result<(), IdeviceError> {
|
pub async fn rsd_checkin(&mut self) -> Result<(), IdeviceError> {
|
||||||
let mut req = plist::Dictionary::new();
|
let req = crate::plist!({
|
||||||
req.insert("Label".into(), self.label.clone().into());
|
"Label": self.label.clone(),
|
||||||
req.insert("ProtocolVersion".into(), "2".into());
|
"ProtocolVersion": "2",
|
||||||
req.insert("Request".into(), "RSDCheckin".into());
|
"Request": "RSDCheckin",
|
||||||
self.send_plist(plist::to_value(&req).unwrap()).await?;
|
});
|
||||||
|
|
||||||
|
self.send_plist(req).await?;
|
||||||
let res = self.read_plist().await?;
|
let res = self.read_plist().await?;
|
||||||
match res.get("Request").and_then(|x| x.as_string()) {
|
match res.get("Request").and_then(|x| x.as_string()) {
|
||||||
Some(r) => {
|
Some(r) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user