I have a Rust program that needs to get data from a C callback function and push to a tokio::net::TcpStream. However, the 'write' function of tokio is async and it does not seem to work with C function
The code looks somewhat like this:
extern "C" fn data_callback(callback_handler: *mut c_void, data: *mut u8, length: i32) {
unsafe {
let mut socket = (&mut *(callback_handler as *mut CallbackHandler)).socket.as_mut().unwrap();
// Prepare data [u8] from data and length
// ....
// Send to socket (await)
socket.write(....).await;
}
}
Is there any workaround for that? Thanks.