use core::future::Future;
pub fn read_sync<F: Future<Output = T>, T>(f: F) -> T {
try_read_sync(f).expect("Failed to read tensor data synchronously. This can happen on platforms that don't support blocking futures like WASM. If possible, try using an async variant of this function instead.")
}
pub fn try_read_sync<F: Future<Output = T>, T>(f: F) -> Option<T> {
#[cfg(target_family = "wasm")]
{
use core::task::Poll;
match embassy_futures::poll_once(f) {
Poll::Ready(output) => Some(output),
_ => None,
}
}
#[cfg(not(target_family = "wasm"))]
{
Some(super::future::block_on(f))
}
}