Skip to content

Uuid

Parsed or generated UUID value.

Constructor

Uuid value

Parses UUID text or binary, or copies an existing Uuid.

Text may be hyphenated, simple, braced, or URN form. Binary values must be exactly 16 bytes.

Parameters

NameTypeDescription
value (Str | Bin | Uuid) UUID to parse or copy.

Errors

ValueError if the text is invalid or bytes are not exactly 16 long.

Example

let id = Uuid "67e55044-10b1-426f-9247-bb680e5fe0c8"
let copy = Uuid $id

Class Fields

MAX

The max Uuid, ffffffff-ffff-ffff-ffff-ffffffffffff.

NIL

The nil Uuid, 00000000-0000-0000-0000-000000000000.

Class Methods

generate() -> Uuid

Generates a random version 4 UUID.

Example

let id = Uuid.generate()
assert_eq $id.version 4
assert_eq $id.variant :RFC4122:

Fields

bytes

The raw 16-byte binary form.

hex

The simple lowercase hexadecimal form without hyphens.

variant

The UUID variant: :NCS:, :RFC4122:, :MICROSOFT:, or :FUTURE:.

version

The UUID version number, such as 4 for a randomly generated UUID.

Methods

(eq) other

Compares two UUID values.

(str)()

Returns the canonical hyphenated UUID text.