sf/utils.rs
1use std::time::{SystemTime, UNIX_EPOCH};
2
3pub fn ms_since_epoch() -> Result<u128, String> {
4 match SystemTime::now().duration_since(UNIX_EPOCH) {
5 Ok(since_epoch) => Ok(u128::from(since_epoch.as_secs()) * 1000
6 + u128::from(since_epoch.subsec_millis())),
7 Err(_) => Err("Time went backwards".to_string()),
8 }
9}