uuid

CUE v0.18.0

Package uuid defines functionality for creating UUIDs as defined in RFC 4122.

Currently only Version 5 (SHA1) and Version 3 (MD5) are supported.

Constants

ns

cue
ns: {
	DNS:  "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
	URL:  "6ba7b811-9dad-11d1-80b4-00c04fd430c8"
	OID:  "6ba7b812-9dad-11d1-80b4-00c04fd430c8"
	X500: "6ba7b814-9dad-11d1-80b4-00c04fd430c8"
	Nil:  "00000000-0000-0000-0000-000000000000"
}

Predefined namespaces

variants

cue
variants: Invalid: 0
variants: RFC4122: 1
variants: Reserved: 2
variants: Microsoft: 3
variants: Future: 4

Invalid UUID

The variant specified in RFC4122

Reserved, NCS backward compatibility.

Reserved, Microsoft Corporation backward compatibility.

Reserved for future definition.

Functions

FromInt

cue
FromInt: func(i: int) -> string

FromInt creates a UUID from an integer.

	DNS:  uuid.FromInt(0x6ba7b810_9dad_11d1_80b4_00c04fd430c8)

MD5

cue
MD5: func(space: string, data: bytes | string) -> string

MD5 generates a version 3 UUID based on the supplied name space and data. Use SHA1 instead if you can.

Parse

cue
Parse: func(s: string) -> string

Parse decodes s into a UUID or returns an error. Both the standard UUID forms of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx are decoded as well as the Microsoft encoding {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} and the raw hex encoding: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.

SHA1

cue
SHA1: func(space: string, data: bytes | string) -> string

SHA1 generates a version 5 UUID based on the supplied name space and data.

ToInt

cue
ToInt: func(x: string) -> int

ToInt represents a UUID string as a 128-bit value.

URN

cue
URN: func(x: string) -> string

URN reports the canonical URN of a UUID.

Valid validator

validator form

cue
validator(string)

call form

cue
func(s: string) -> _

Valid ensures that s is a valid UUID which would be accepted by Parse.

Variant

cue
Variant: func(x: string) -> int

Variant reports the UUID variant.

Version

cue
Version: func(x: string) -> int

Version reports the UUID version.

Install CUE