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

DataError 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 @ Uuid [get, set]

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

NIL @ Uuid [get, set]

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 @ Bin [get]

The raw 16-byte binary form.

hex @ Str [get]

The simple lowercase hexadecimal form without hyphens.

variant @ (:NCS: | :RFC4122: | :MICROSOFT: | :FUTURE:) [get]

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

version @ Int [get]

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

Methods

(eq) other -> Bool

Compares two UUID values.

Parameters

NameTypeDescription
other Value

(lt) other -> Bool

Orders two UUID values.

Parameters

NameTypeDescription
other Uuid

(str)() -> Str

Returns the canonical hyphenated UUID text.