let vpn_client: Arc<futures::lock::Mutex<dyn VpnClient>> = ...
let on_virtual_tun_write = Arc::new(
move |f: &mut dyn FnMut(&mut [u8]),size: usize| -> std::result::Result<(), VirtualTunWriteError> {
let mut buffer = vec![0; size];
f(buffer.as_mut_slice());
match vpn_client_.lock().await.send(buffer.as_slice())
//...
As you can see in the example above, I have an Arc<futures::lock::Mutex<dyn VpnClient>>. I use it for other things in async code, but there's a library that which accepts on_virtual_tun_write which is not async, , so I cannot lock() this mutex inside of this callback.
How could I lock().await this mutex outside of some async code? And is this a good solution? I cannot use non async Mutex because of the rest of the code.