1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
use std::{future::Future, time::Duration};
#[derive(Debug)]
pub struct TimeoutError;
pub async fn timeout<F, T>(_: Duration, _: F) -> Result<T, TimeoutError>
where
F: Future<Output = T>,
{
Err(TimeoutError)
}
impl std::fmt::Display for TimeoutError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Please enable a runtime")
}
}
impl std::error::Error for TimeoutError {}