Functions

createType1AsRecord
I

Returns a UUID of type 1 as a UUID record.

createType1AsString
I

Returns a UUID of type 1 as a string.

createType3AsRecord
I

Returns a UUID of type 3 as a UUID record.

createType3AsString
I

Returns a UUID of type 3 as a string.

createType4AsRecord
I

Returns a UUID of type 4 as a UUID record.

createType4AsString
I

Returns a UUID of type 4 as a string.

createType5AsRecord
I

Returns a UUID of type 5 as a UUID record.

createType5AsString
I

Returns a UUID of type 5 as a string.

getVersion
I

Detect RFC version of a UUID.

nilAsRecord
I

Returns a nil UUID as a UUID record.

nilAsString
I

Returns a nil UUID as a string.

toBytes
I

Convert to an array of bytes.

toRecord
I

Convert to UUID record.

toString
I

Convert to UUID string.

validate
I

Test a string to see if it is a valid UUID.

createType1AsRecord

function createType1AsRecord() returns Uuid | Error
Isolated Function

Returns a UUID of type 1 as a UUID record.

1uuid:Uuid|uuid:Error uuid1 = uuid:createType1AsRecord();

Return Type

(Uuid | Error)

UUID of type 1 as a UUID record or error

createType1AsString

function createType1AsString() returns string
Isolated Function

Returns a UUID of type 1 as a string.

1string uuid1 = uuid:createType1AsString();

Return Type

(string)

UUID of type 1 as a string

createType3AsRecord

function createType3AsRecord(NamespaceUUID namespace, string name) returns Uuid | Error
Isolated Function

Returns a UUID of type 3 as a UUID record.

1uuid:Uuid|uuid:Error uuid3 = uuid:createType3AsRecord(uuid:NAME_SPACE_DNS, “ballerina.io”);

Parameters

  • namespace NamespaceUUID
  • string representation for pre-defined namespace UUIDs

  • name string
  • a name within the namespace

Return Type

(Uuid | Error)

UUID of type 3 as a UUID record or error

createType3AsString

function createType3AsString(NamespaceUUID namespace, string name) returns string | Error
Isolated Function

Returns a UUID of type 3 as a string.

1string|uuid:Error uuid3 = uuid:createType3AsString(uuid:NAME_SPACE_DNS, “ballerina.io”);

Parameters

  • namespace NamespaceUUID
  • string representation for pre-defined namespace UUIDs

  • name string
  • a name within the namespace

Return Type

(string | Error)

UUID of type 3 as a string

createType4AsRecord

function createType4AsRecord() returns Uuid | Error
Isolated Function

Returns a UUID of type 4 as a UUID record.

1uuid:Uuid|uuid:Error uuid4 = uuid:createType4AsRecord();

Return Type

(Uuid | Error)

UUID of type 4 as a UUID record or error

createType4AsString

function createType4AsString() returns string
Isolated Function

Returns a UUID of type 4 as a string.

1string uuid4 = uuid:createType4AsString();

Return Type

(string)

UUID of type 4 as a string

createType5AsRecord

function createType5AsRecord(NamespaceUUID namespace, string name) returns Uuid | Error
Isolated Function

Returns a UUID of type 5 as a UUID record.

1uuid:Uuid|uuid:Error uuid5 = uuid:createType5AsRecord(uuid:NAME_SPACE_DNS, “ballerina.io”);

Parameters

  • namespace NamespaceUUID
  • string representation for pre-defined namespace UUIDs

  • name string
  • a name within the namespace

Return Type

(Uuid | Error)

UUID of type 5 as a UUID record or error

createType5AsString

function createType5AsString(NamespaceUUID namespace, string name) returns string | Error
Isolated Function

Returns a UUID of type 5 as a string.

1string|uuid:Error uuid5 = uuid:createType5AsString(uuid:NAME_SPACE_DNS, “ballerina.io”);

Parameters

  • namespace NamespaceUUID
  • string representation for pre-defined namespace UUIDs

  • name string
  • a name within the namespace

Return Type

(string | Error)

UUID of type 5 as a string

getVersion

function getVersion(string uuid) returns Version | Error
Isolated Function

Detect RFC version of a UUID. Returns an error if the UUID is invalid.

1uuid:Version|uuid:Error v = uuid:getVersion("4397465e-35f9-11eb-adc1-0242ac120002");

Parameters

Return Type

(Version | Error)

UUID version, or error

nilAsRecord

function nilAsRecord() returns Uuid
Isolated Function

Returns a nil UUID as a UUID record.

1uuid:Uuid nilUUID = uuid:nilAsRecord();

Return Type

(Uuid)

nil UUID

nilAsString

function nilAsString() returns string
Isolated Function

Returns a nil UUID as a string.

1string nilUUID = uuid:nilAsString();

Return Type

(string)

nil UUID

toBytes

function toBytes(string | Uuid uuid) returns byte[ ] | Error
Isolated Function

Convert to an array of bytes. Returns an error if the UUID is invalid.

1byte[]|uuid:Error b = uuid:toBytes(“6ec0bd7f-11c0-43da-975e-2aesass0b”);

Parameters

Return Type

(byte[ ] | Error)

UUID as bytes

toRecord

function toRecord(string | byte[ ] uuid) returns Uuid | Error
Isolated Function

Convert to UUID record. Returns error if the array is invalid.

1uuid:Uuid|uuid:Error r1 = uuid:toRecord("4397465e-35f9-11eb-adc1-0242ac120002");
2uuid:Uuid|uuid:Error r2 = uuid:toRecord([10, 20, 30]);

Parameters

  • uuid string | byte[ ]
  • UUID to be converted

Return Type

(Uuid | Error)

UUID as record

toString

function toString(byte[ ] | Uuid uuid) returns string | error
Isolated Function

Convert to UUID string. Returns error if the array is invalid.

1string|error s = uuid:toString([5, 12, 16, 35]);

Parameters

  • uuid byte[ ] | Uuid
  • UUID to be converted

Return Type

(string | error)

UUID as string

validate

function validate(string uuid) returns boolean
Isolated Function

Test a string to see if it is a valid UUID.

1boolean valid = uuid:validate("4397465e-35f9-11eb-adc1-0242ac120002");

Parameters

Return Type

(boolean)

true if a valied UUID, false if not