#![forbid(unsafe_code)]
#[allow(
dead_code,
reason = "only called from wasm32-only wasm.rs; exercised directly by host-side unit tests below"
)]
#[allow(
clippy::redundant_pub_crate,
reason = "explicit crate-only scope, even though the parent `timestamp` module is also private"
)]
#[must_use]
pub(crate) fn timestamp_us_to_i32(timestamp_us: f64) -> Option<i32> {
if !timestamp_us.is_finite()
|| timestamp_us < f64::from(i32::MIN)
|| timestamp_us > f64::from(i32::MAX)
{
return None;
}
#[allow(
clippy::cast_possible_truncation,
reason = "bounds-checked against i32::MIN/MAX just above the cast"
)]
Some(timestamp_us as i32)
}
#[cfg(test)]
#[path = "timestamp_tests.rs"]
mod tests;