std.uuid - ZZ
v4/v7 generation, parse (normalizing), validation. v7 is time-ordered — good for request IDs and DB keys.
import std.uuidPurpose
Section titled “Purpose”std.uuid generates UUID v4 (random) and v7 (time-ordered), parses and normalizes UUID strings, and validates shape. v7 sorts roughly by creation time — prefer it for IDs appearing in logs and indexes.
Quickstart
Section titled “Quickstart”import std.uuid
println(uuid.v4()) // random, e.g. "f47ac10b-58cc-4372-a567-0e02b2c3d479"println(uuid.v7()) // time-ordered (good for request IDs, DB keys)s := uuid.v4()println(uuid.parse(s)) // normalized or .errprintln(uuid.is_valid(s)) // boolProduction patterns
Section titled “Production patterns”import std.uuid
func main() -> Result<int, str> { // Request ID for tracing req_id := uuid.v7() // time-ordered, sortable in logs println(req_id)
// External ID validation external := "f47ac10b-58cc-4372-a567-0e02b2c3d479" if uuid.is_valid(external) { id := uuid.parse(external)? println(id) } return .ok(0)}API reference
Section titled “API reference”4 entries. Signatures come from the compiler’s own FuncSig table, so they match the runtime exactly; descriptions come from the module guide.
See also
Section titled “See also”std.encoding— Codecs: base64, hex, URL encoding and JSON escaping.std.crypto— Digests, HMAC, random bytes and password hashing.
Full index: API reference · Standard library