atomic-snowflake 11.1.0

Zero-dependency lock-free monotonic 64-bit Snowflake ID, 128-bit ULID, and RFC 9562 UUIDv7 generators with stack-buffered Crockford Base32 and hyphenated hex codecs.
Documentation
use super::*;

/// Returns the current Unix wall-clock timestamp in milliseconds.
///
/// # Returns
///
/// - `u64` - Milliseconds since Unix epoch (`0` if system clock precedes 1970).
#[inline(always)]
pub(crate) fn current_unix_ms() -> u64 {
    match SystemTime::now().duration_since(UNIX_EPOCH) {
        Ok(duration) => u64::try_from(duration.as_millis()).unwrap_or(u64::MAX),
        Err(_) => 0,
    }
}

/// Mixes a 64-bit state word using SplitMix64 for fast non-cryptographic entropy.
///
/// # Arguments
///
/// - `u64` - Input state word.
///
/// # Returns
///
/// - `u64` - Well-distributed 64-bit output word.
#[inline(always)]
pub(crate) fn splitmix64(mut x: u64) -> u64 {
    x = x.wrapping_add(0x9e37_79b9_7f4a_7c15);
    x = (x ^ (x >> 30)).wrapping_mul(0xbf58_476d_1ce4_e5b9);
    x = (x ^ (x >> 27)).wrapping_mul(0x94d0_49bb_1331_11eb);
    x ^ (x >> 31)
}