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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use super::*;

/// An RFC 9562 time-ordered 128-bit UUIDv7 identifier.
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct UuidV7 {
    /// Raw big-endian 128-bit UUID value.
    pub(crate) raw: u128,
}

/// Lock-free monotonic RFC 9562 UUIDv7 generator (`48-bit ts | ver=7 | 12-bit seq | var=10 | 62-bit rnd`).
#[derive(Debug)]
pub struct UuidV7Generator {
    /// Packed `(last_ms_48 << 12) | last_seq_12` atomic counter.
    pub(crate) state: AtomicU64,
    /// Rolling SplitMix64 entropy seed for the 62-bit `rand_b` field.
    pub(crate) seed: AtomicU64,
}