mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 14:36:16 +01:00
Implement FFI for App Service
This commit is contained in:
@@ -130,13 +130,19 @@ pub struct IconUuid {
|
||||
pub classes: Vec<String>,
|
||||
}
|
||||
|
||||
impl<R: ReadWrite> AppServiceClient<R> {
|
||||
impl<'a, R: ReadWrite + 'a> AppServiceClient<R> {
|
||||
pub async fn new(stream: R) -> Result<Self, IdeviceError> {
|
||||
Ok(Self {
|
||||
inner: CoreDeviceServiceClient::new(stream).await?,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn box_inner(self) -> AppServiceClient<Box<dyn ReadWrite + 'a>> {
|
||||
AppServiceClient {
|
||||
inner: self.inner.box_inner(),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn list_apps(
|
||||
&mut self,
|
||||
app_clips: bool,
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::{
|
||||
};
|
||||
|
||||
mod app_service;
|
||||
pub use app_service::{AppListEntry, AppServiceClient};
|
||||
pub use app_service::*;
|
||||
|
||||
const CORE_SERVICE_VERSION: &str = "443.18";
|
||||
|
||||
@@ -17,13 +17,19 @@ pub struct CoreDeviceServiceClient<R: ReadWrite> {
|
||||
inner: RemoteXpcClient<R>,
|
||||
}
|
||||
|
||||
impl<R: ReadWrite> CoreDeviceServiceClient<R> {
|
||||
impl<'a, R: ReadWrite + 'a> CoreDeviceServiceClient<R> {
|
||||
pub async fn new(inner: R) -> Result<Self, IdeviceError> {
|
||||
let mut client = RemoteXpcClient::new(inner).await?;
|
||||
client.do_handshake().await?;
|
||||
Ok(Self { inner: client })
|
||||
}
|
||||
|
||||
pub fn box_inner(self) -> CoreDeviceServiceClient<Box<dyn ReadWrite + 'a>> {
|
||||
CoreDeviceServiceClient {
|
||||
inner: self.inner.box_inner(),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn invoke(
|
||||
&mut self,
|
||||
feature: impl Into<String>,
|
||||
|
||||
@@ -23,7 +23,7 @@ impl<R: ReadWrite> RsdService for RestoreServiceClient<R> {
|
||||
type Stream = R;
|
||||
}
|
||||
|
||||
impl<R: ReadWrite> RestoreServiceClient<R> {
|
||||
impl<'a, R: ReadWrite + 'a> RestoreServiceClient<R> {
|
||||
/// Creates a new Restore Service client a socket connection,
|
||||
/// and connects to the RemoteXPC service.
|
||||
///
|
||||
@@ -35,6 +35,12 @@ impl<R: ReadWrite> RestoreServiceClient<R> {
|
||||
Ok(Self { stream })
|
||||
}
|
||||
|
||||
pub fn box_inner(self) -> RestoreServiceClient<Box<dyn ReadWrite + 'a>> {
|
||||
RestoreServiceClient {
|
||||
stream: self.stream.box_inner(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Enter recovery
|
||||
pub async fn enter_recovery(&mut self) -> Result<(), IdeviceError> {
|
||||
let mut req = Dictionary::new();
|
||||
|
||||
@@ -17,7 +17,7 @@ pub struct Http2Client<R: ReadWrite> {
|
||||
cache: HashMap<u32, VecDeque<Vec<u8>>>,
|
||||
}
|
||||
|
||||
impl<R: ReadWrite> Http2Client<R> {
|
||||
impl<'a, R: ReadWrite + 'a> Http2Client<R> {
|
||||
/// Writes the magic and inits the caches
|
||||
pub async fn new(mut inner: R) -> Result<Self, IdeviceError> {
|
||||
inner.write_all(HTTP2_MAGIC).await?;
|
||||
@@ -28,6 +28,13 @@ impl<R: ReadWrite> Http2Client<R> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn box_inner(self) -> Http2Client<Box<dyn ReadWrite + 'a>> {
|
||||
Http2Client {
|
||||
inner: Box::new(self.inner),
|
||||
cache: self.cache,
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn set_settings(
|
||||
&mut self,
|
||||
settings: Vec<frame::Setting>,
|
||||
|
||||
@@ -20,7 +20,7 @@ pub struct RemoteXpcClient<R: ReadWrite> {
|
||||
reply_id: u64,
|
||||
}
|
||||
|
||||
impl<R: ReadWrite> RemoteXpcClient<R> {
|
||||
impl<'a, R: ReadWrite + 'a> RemoteXpcClient<R> {
|
||||
pub async fn new(socket: R) -> Result<Self, IdeviceError> {
|
||||
Ok(Self {
|
||||
h2_client: http2::Http2Client::new(socket).await?,
|
||||
@@ -29,6 +29,14 @@ impl<R: ReadWrite> RemoteXpcClient<R> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn box_inner(self) -> RemoteXpcClient<Box<dyn ReadWrite + 'a>> {
|
||||
RemoteXpcClient {
|
||||
h2_client: self.h2_client.box_inner(),
|
||||
root_id: self.root_id,
|
||||
reply_id: self.reply_id,
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn do_handshake(&mut self) -> Result<(), IdeviceError> {
|
||||
self.h2_client
|
||||
.set_settings(
|
||||
|
||||
Reference in New Issue
Block a user