Rewrite async runtime handling and port to tracing

This commit is contained in:
Jackson Coxson
2025-10-23 12:29:59 -06:00
parent 7527cdff7b
commit 7da735f141
28 changed files with 267 additions and 167 deletions

View File

@@ -6,7 +6,7 @@ use std::ptr::null_mut;
use idevice::{IdeviceError, IdeviceService, misagent::MisagentClient, provider::IdeviceProvider};
use crate::{IdeviceFfiError, RUNTIME, ffi_err, provider::IdeviceProviderHandle};
use crate::{IdeviceFfiError, ffi_err, provider::IdeviceProviderHandle, run_sync_local};
pub struct MisagentClientHandle(pub MisagentClient);
@@ -32,7 +32,7 @@ pub unsafe extern "C" fn misagent_connect(
return ffi_err!(IdeviceError::FfiInvalidArg);
}
let res: Result<MisagentClient, IdeviceError> = RUNTIME.block_on(async move {
let res: Result<MisagentClient, IdeviceError> = run_sync_local(async move {
let provider_ref: &dyn IdeviceProvider = unsafe { &*(*provider).0 };
MisagentClient::connect(provider_ref).await
});
@@ -72,7 +72,7 @@ pub unsafe extern "C" fn misagent_install(
let profile = unsafe { std::slice::from_raw_parts(profile_data, profile_len) }.to_vec();
let res = RUNTIME.block_on(async { unsafe { &mut *client }.0.install(profile).await });
let res = run_sync_local(async { unsafe { &mut *client }.0.install(profile).await });
match res {
Ok(_) => null_mut(),
@@ -105,7 +105,7 @@ pub unsafe extern "C" fn misagent_remove(
.to_string_lossy()
.into_owned();
let res = RUNTIME.block_on(async { unsafe { &mut *client }.0.remove(&id).await });
let res = run_sync_local(async { unsafe { &mut *client }.0.remove(&id).await });
match res {
Ok(_) => null_mut(),
@@ -143,7 +143,7 @@ pub unsafe extern "C" fn misagent_copy_all(
}
let res: Result<Vec<Vec<u8>>, IdeviceError> =
RUNTIME.block_on(async { unsafe { &mut *client }.0.copy_all().await });
run_sync_local(async { unsafe { &mut *client }.0.copy_all().await });
match res {
Ok(profiles) => {