Skip to main content

somatize_core/
util.rs

1//! Shared utility functions.
2
3use std::time::{SystemTime, UNIX_EPOCH};
4
5/// Generate a hex-encoded nanosecond timestamp ID with a prefix.
6///
7/// Used for unique run IDs, plan IDs, etc.
8pub fn timestamp_id(prefix: &str) -> String {
9    let nanos = SystemTime::now()
10        .duration_since(UNIX_EPOCH)
11        .unwrap_or_default()
12        .as_nanos();
13    format!("{prefix}_{nanos:x}")
14}