use std::{future::Future, io}; use tokio::task; /// Copied from tokio https://docs.rs/tokio/latest/src/tokio/fs/mod.rs.html#132 pub(super) fn asyncify(f: F) -> impl Future> + Send + Sync + 'static where F: FnOnce() -> io::Result + Send + 'static, T: Send + 'static, { async fn inner(handle: task::JoinHandle>) -> io::Result { match handle.await { Ok(res) => res, Err(err) => Err(io::Error::new( io::ErrorKind::Other, format!("background task failed: {err}"), )), } } inner(task::spawn_blocking(f)) }