nx_uuid_v1.nx
buildroot/runtime/nx_uuid_v1.nx
about
uuid.nx -- UUID v4 (random) + v7 (time-ordered) generators.
RFC 4122 (v4) + draft-ietf-uuidrev-rfc4122bis (v7). 16-byte
identifier, formatted as 36-char hex string with hyphens.
v4 = 122 random bits + 6 deterministic version/variant bits.
Use when you don't need lexicographic time-ordering.
v7 = 48-bit Unix ms timestamp prefix + 74 random bits + 6
version/variant bits. Sorts lexicographically by creation
time, which is huge for database indexes -- rows cluster
instead of scattering, and clustered B-trees stay warm.
Use in preference to v4 for new systems.
Invariants:
U1 Every byte of the non-version/variant space is from
/dev/urandom (via rand.nx). No PRNG state persists; each
UUID is an independent sample.
U2 Version + variant bits exactly match the RFC specs at
byte positions 6 (version) and 8 (variant).
U3 v7 timestamp is milliseconds since epoch, big-endian in
bytes 0..5. Enables lexicographic time-ordering.
U4 Formatting is deterministic: lowercase hex, no prefix,
exact dash placement at 8-4-4-4-12 positions.
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_rand.nxnx_hex_codec.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| none |
functions
| 40 | func uuid_v4_bytes(out: *u8) -> i64 |
| 55 | func uuid_v7_bytes(unix_ms: i64, out: *u8) -> i64 |
| 85 | func uuid_format(bytes: *u8, out: *u8) -> i64 |
| 124 | func uuid_v4_string(out: *u8) -> i64 |
| 131 | func uuid_v7_string(unix_ms: i64, out: *u8) -> i64 |
| 139 | func main() -> i64 |