#[cfg(target_family = "wasm")]
use std::time::Duration;
#[cfg(not(target_family = "wasm"))]
pub(crate) use std::time::Instant;
#[cfg(target_family = "wasm")]
#[derive(Clone, Copy, Debug)]
pub(crate) struct Instant(Duration);
#[cfg(target_family = "wasm")]
impl Instant {
pub(crate) fn now() -> Self {
Self(Duration::ZERO)
}
pub(crate) fn elapsed(&self) -> Duration {
self.0
}
}
#[cfg(not(target_family = "wasm"))]
pub(crate) fn default_base_seed() -> u64 {
std::time::SystemTime::now()
.duration_since(std::time::SystemTime::UNIX_EPOCH)
.map_or(12345, |d| u64::try_from(d.as_nanos()).unwrap_or(u64::MAX))
}
#[cfg(target_family = "wasm")]
pub(crate) fn default_base_seed() -> u64 {
tracing::warn!(
"no base seed set on wasm; using fixed seed 0 (set a seed explicitly for determinism)"
);
0
}