code wiki / (root) / uuid.nx

uuid.nx

buildroot/runtime/uuid.nx

5168 B146 linesdepth 4pulls 5 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

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

syscalls.nx rand.nx hex.nx uuid.nx

imports: syscalls.nxrand.nxhex.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main uuid_v4_string uuid_v4_bytes rand_bytes rand_open_urandom sys_read uuid_format hex_encode

structs

none

consts

none

functions

34func uuid_v4_bytes(out: *u8) -> i64 {
called by 1: uuid_v4_string calls 1: rand_bytes
49func uuid_v7_bytes(unix_ms: i64, out: *u8) -> i64 {
called by 1: uuid_v7_string calls 1: rand_bytes
79func uuid_format(bytes: *u8, out: *u8) -> i64 {
118func uuid_v4_string(out: *u8) -> i64 {
called by 1: main calls 2: uuid_v4_bytesuuid_format
125func uuid_v7_string(unix_ms: i64, out: *u8) -> i64 {
133func main() -> i64 {
calls 1: uuid_v4_string