use std::time::{SystemTime, UNIX_EPOCH}; /// A timestamp since the unix epoch pub type Timestamp = i64; /// Get the current system timestamp pub fn current_timestamp() -> Timestamp { let now = SystemTime::now(); // A duration is always positive so this returns an unsigned integer, while a timestamp can // predate the unix epoch so we must cast to a signed integer. now.duration_since(UNIX_EPOCH) .expect("Time moves forward") .as_secs() as i64 }