use std::future::Future;
use tokio::runtime::Runtime;
pub fn run_async<F, T>(future: F) -> T
where
F: Future<Output = T> + Send,
T: Send,
{
let rt = Runtime::new().expect("Failed to create Tokio runtime");
rt.block_on(future)
}
pub fn block_on_tokio_task<F, T>(future: F) -> T
where
F: Future<Output = T> + Send + 'static,
T: Send + 'static,
{
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("Failed to build Tokio runtime for task");
rt.block_on(future)
}