I want to use library with synchronous file IO in asynchronous application. I also want all file operations work asynchronously. Is that possible? Something like this:
// function in other crate with synchronous API
fn some_api_fun_with_sync_io(r: &impl std::io::Read) -> Result<(), std::io::Error> {
// ...
}
async fn my_fun() -> anyhow::Result<()> {
let mut async_file = async_std::fs::File::open("test.txt").await?;
// I want some magic here ))
let mut sync_file = magic_async_to_sync_converter(async_file);
some_api_fun_with_sync_io(&mut sync_file)?;
Ok(())
}