pub mod maybe_future {
#[cfg(feature = "async")]
pub type MaybeFuture<'a, T> = futures::future::BoxFuture<'a, T>;
#[cfg(not(feature = "async"))]
pub type MaybeFuture<'a, T> = T;
}
#[macro_export]
macro_rules! ret {
($ex:expr) => {
#[cfg(feature = "async")]
return async move { $ex.await }.boxed();
#[cfg(not(feature = "async"))]
return crate::maybe_future::RUNTIME.block_on($ex);
};
}
#[cfg(not(feature = "async"))]
pub(crate) static RUNTIME: once_cell::sync::Lazy<tokio::runtime::Runtime> =
once_cell::sync::Lazy::new(|| {
tokio::runtime::Builder::new_current_thread()
.enable_io()
.enable_time()
.build()
.unwrap()
});