std/uuid

UUIDs (RFC 9562), with random bits from the system.

import "std/uuid"

Uuid id = uuid7()
print(id.text())                       // 01936d3c-5a7e-7cc2-9f10-...
Uuid same = parse_uuid(id.text())?
Function or method Result
uuid4() a random UUID, version 4
uuid7() a UUID of version 7: the time in milliseconds, a counter, and random bits, so those made later sort after, even within a millisecond
nil_uuid() all zeros
parse_uuid(text) the UUID text writes: with or without hyphens, in braces, or after urn:uuid:; an ERROR of kind "invalid_uuid" otherwise
u.text(), u.version(), u.time_ms(), u.equals(other) its text, its version, when a version 7 UUID was made, and whether two are the same; u.value is its 16 bytes