Axle v0.14.1
Package

std/text/uuid

std/uuid — RFC 4122 UUID v4 (random) generation and parsing.

Generation is backed by std/random's xoshiro256 stream — fast,
but NOT suitable for security tokens (the seed is wall-clock-based
and observable). Use a real CSPRNG for crypto-grade IDs; this module
is for "a unique-enough string for a log line / cache key".

Generation stays native (shared global RNG state). Validation and
normalisation are pure Axle: both accept either the canonical
36-character dashed form or any dash placement, requiring exactly 32
hex digits once dashes are removed.

Free functions

TypeMethod and description
string
uuidV4() : string A fresh random (RFC 4122 v4) UUID in canonical 36-character dashed
form, e.g. "f81d4fae-7dec-41d0-a765-00a0c91e6bf6". Not for security
tokens — see the module header.
string
uuidV4Hex() : string A fresh random v4 UUID as 32 hex digits with no dashes.
bool
uuidIsValid(s : string) : bool true when s is a valid UUID: removing every '-' must leave
exactly 32 hex digits.
string
uuidNormalize(s : string) : string Validate s, then return its 32 hex digits with dashes removed and
any uppercase digits lowered. Raises ParseException when s is not
a valid UUID.

Method detail

#uuidV4

uuidV4() : string

A fresh random (RFC 4122 v4) UUID in canonical 36-character dashed
form, e.g. "f81d4fae-7dec-41d0-a765-00a0c91e6bf6". Not for security
tokens — see the module header.

#uuidV4Hex

uuidV4Hex() : string

A fresh random v4 UUID as 32 hex digits with no dashes.

#uuidIsValid

uuidIsValid(s : string) : bool

true when s is a valid UUID: removing every '-' must leave
exactly 32 hex digits.

Parameters
s candidate UUID string to validate

#uuidNormalize

uuidNormalize(s : string) : string ! ParseException

Validate s, then return its 32 hex digits with dashes removed and
any uppercase digits lowered. Raises ParseException when s is not
a valid UUID.

Parameters
s UUID string to validate and canonicalise