Loading RustViz Engine...
Race an async future against a timer and gracefully abort on expiration.
This problem is currently in blueprint template mode. Once the concept foundation is finalized, live in-browser WebAssembly compilation and test assertion runners will be enabled here.
// Simulates async timeout race
pub async fn execute_with_timeout<F: std::future::Future>(f: F, timeout_ms: u64) -> Result<F::Output, ()> {
// Under Tokio: tokio::select! { res = f => Ok(res), _ = sleep(timeout_ms) => Err(()) }
let res = f.await;
let _ = timeout_ms;
Ok(res)
}