Add adapter_close to stop TCP stack

This commit is contained in:
Jackson Coxson
2025-10-22 10:26:13 -06:00
parent dd2db92967
commit 5ed2144d9e
4 changed files with 80 additions and 30 deletions

View File

@@ -103,7 +103,9 @@ pub unsafe extern "C" fn adapter_pcap(
/// # Safety
/// `handle` must be a valid pointer to a handle allocated by this library
#[unsafe(no_mangle)]
pub unsafe extern "C" fn adapter_close(handle: *mut AdapterStreamHandle) -> *mut IdeviceFfiError {
pub unsafe extern "C" fn adapter_stream_close(
handle: *mut AdapterStreamHandle,
) -> *mut IdeviceFfiError {
if handle.is_null() {
return ffi_err!(IdeviceError::FfiInvalidArg);
}
@@ -114,6 +116,28 @@ pub unsafe extern "C" fn adapter_close(handle: *mut AdapterStreamHandle) -> *mut
null_mut()
}
/// Stops the entire adapter TCP stack
///
/// # Arguments
/// * [`handle`] - The adapter handle
///
/// # Returns
/// Null on success, an IdeviceFfiError otherwise
///
/// # Safety
/// `handle` must be a valid pointer to a handle allocated by this library
#[unsafe(no_mangle)]
pub unsafe extern "C" fn adapter_close(handle: *mut AdapterHandle) -> *mut IdeviceFfiError {
if handle.is_null() {
return ffi_err!(IdeviceError::FfiInvalidArg);
}
let adapter = unsafe { &mut (*handle).0 };
RUNTIME.block_on(async move { adapter.close().await.ok() });
null_mut()
}
/// Sends data through the adapter stream
///
/// # Arguments