gdDocumentation0.8.0

API reference

GD.id

Entry for generating and checking UUIDs and time-ordered ULIDs. Timestamp -1 selects the current time; other values outside the 48-bit range return an empty string. Encoded overflow is rejected.

Methods

ulid

ulid(ms: int = -1) -> String

Create a ULID for the specified time.

Parameters

NameTypeDefaultDescription
msint-1Timestamp or duration in milliseconds, as specified by this method.

Return value

String

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

is_ulid

is_ulid(text: String) -> bool

Check whether text is a ULID.

Parameters

NameTypeDefaultDescription
textStringRequiredText to inspect, decode or transform; the input is not modified in place.

Return value

bool

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

ulid_time

ulid_time(text: String) -> int, Err

Read the timestamp from a ULID.

Parameters

NameTypeDefaultDescription
textStringRequiredText to inspect, decode or transform; the input is not modified in place.

Return value

int, Err

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

uuid

uuid() -> String

Create a random version-4 UUID.

Parameters

No parameters.

Return value

String

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

uuid_v5

uuid_v5(space: String, name: String) -> String, Err

Create a name-based version-5 UUID.

Parameters

NameTypeDefaultDescription
spaceStringRequiredUUID namespace used with the supplied name.
nameStringRequiredName used to register or look up the corresponding entry.

Return value

String, Err

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

uuid_v5_async

uuid_v5_async(space: String, name: String) -> await String, Err

Dispatch UUID generation for long names to a CPU worker.

Parameters

NameTypeDefaultDescription
spaceStringRequiredUUID namespace used with the supplied name.
nameStringRequiredName used to register or look up the corresponding entry.

Return value

await String, Err

Returns a Signal. Use await to receive the completion value shown in the signature.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

is_uuid

is_uuid(text: String) -> bool

Check whether text is a UUID.

Parameters

NameTypeDefaultDescription
textStringRequiredText to inspect, decode or transform; the input is not modified in place.

Return value

bool

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

uuid_bytes

uuid_bytes(text: String) -> PackedByteArray, Err

Convert a UUID to 16 bytes.

Parameters

NameTypeDefaultDescription
textStringRequiredText to inspect, decode or transform; the input is not modified in place.

Return value

PackedByteArray, Err

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

uuid_version

uuid_version(text: String) -> int

Return a UUID's version.

Parameters

NameTypeDefaultDescription
textStringRequiredText to inspect, decode or transform; the input is not modified in place.

Return value

int

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

nil_uuid

nil_uuid() -> String

Return the nil UUID.

Parameters

No parameters.

Return value

String

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

dns_namespace

dns_namespace() -> String

Return the DNS UUID namespace.

Parameters

No parameters.

Return value

String

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

url_namespace

url_namespace() -> String

Return the URL UUID namespace.

Parameters

No parameters.

Return value

String

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

oid_namespace

oid_namespace() -> String

Return the OID UUID namespace.

Parameters

No parameters.

Return value

String

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.