use core::time::Duration;
#[cfg(all(feature = "std", not(feature = "wasm32_web_time")))]
pub use std::time::Instant;
#[cfg(feature = "wasm32_web_time")]
pub use web_time::Instant;
#[cfg(not(any(feature = "std", feature = "wasm32_web_time")))]
pub type Instant = ();
pub fn deadline_exceeded(deadline: Option<Instant>) -> bool {
match deadline {
#[allow(unused)]
Some(deadline) => {
#[cfg(not(any(feature = "std", feature = "wasm32_web_time")))]
{
false
}
#[cfg(any(feature = "std", feature = "wasm32_web_time"))]
{
Instant::now() > deadline
}
}
None => false,
}
}
#[allow(unused)]
pub fn duration_to_deadline(add: Duration) -> Option<Instant> {
#[cfg(not(any(feature = "std", feature = "wasm32_web_time")))]
{
None
}
#[cfg(any(feature = "std", feature = "wasm32_web_time"))]
{
Instant::now().checked_add(add)
}
}