mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 22:46:14 +01:00
Rewrite async runtime handling and port to tracing
This commit is contained in:
@@ -6,7 +6,9 @@ use idevice::{
|
||||
IdeviceError, IdeviceService, heartbeat::HeartbeatClient, provider::IdeviceProvider,
|
||||
};
|
||||
|
||||
use crate::{IdeviceFfiError, IdeviceHandle, RUNTIME, ffi_err, provider::IdeviceProviderHandle};
|
||||
use crate::{
|
||||
IdeviceFfiError, IdeviceHandle, ffi_err, provider::IdeviceProviderHandle, run_sync_local,
|
||||
};
|
||||
|
||||
pub struct HeartbeatClientHandle(pub HeartbeatClient);
|
||||
|
||||
@@ -32,7 +34,7 @@ pub unsafe extern "C" fn heartbeat_connect(
|
||||
return ffi_err!(IdeviceError::FfiInvalidArg);
|
||||
}
|
||||
|
||||
let res: Result<HeartbeatClient, IdeviceError> = RUNTIME.block_on(async move {
|
||||
let res: Result<HeartbeatClient, IdeviceError> = run_sync_local(async move {
|
||||
let provider_ref: &dyn IdeviceProvider = unsafe { &*(*provider).0 };
|
||||
// Connect using the reference
|
||||
HeartbeatClient::connect(provider_ref).await
|
||||
@@ -95,7 +97,7 @@ pub unsafe extern "C" fn heartbeat_send_polo(
|
||||
if client.is_null() {
|
||||
return ffi_err!(IdeviceError::FfiInvalidArg);
|
||||
}
|
||||
let res: Result<(), IdeviceError> = RUNTIME.block_on(async move {
|
||||
let res: Result<(), IdeviceError> = run_sync_local(async move {
|
||||
let client_ref = unsafe { &mut (*client).0 };
|
||||
client_ref.send_polo().await
|
||||
});
|
||||
@@ -126,7 +128,7 @@ pub unsafe extern "C" fn heartbeat_get_marco(
|
||||
if client.is_null() || new_interval.is_null() {
|
||||
return ffi_err!(IdeviceError::FfiInvalidArg);
|
||||
}
|
||||
let res: Result<u64, IdeviceError> = RUNTIME.block_on(async move {
|
||||
let res: Result<u64, IdeviceError> = run_sync_local(async move {
|
||||
let client_ref = unsafe { &mut (*client).0 };
|
||||
client_ref.get_marco(interval).await
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user