use std::future::Future; use std::task::{Context, Poll}; use futures_util::task::noop_waker_ref; use tokio::pin; pub fn sync_future(future: impl Future) -> anyhow::Result { let waker = noop_waker_ref(); let mut context = Context::from_waker(waker); pin!(future); if let Poll::Ready(a) = future.poll(&mut context) { Ok(a) } else { Err(anyhow::Error::msg("Future has suspended")) } }