protocol

typeid_protocol

Type-safe, K-sortable, globally unique identifier (TypeID) generator protocol.

Availability:
logtalk_load(typeid(loader))
Author: Paulo Moura
Version: 1:0:0
Date: 2026-07-24
Compilation flags:
static
Dependencies:
(none)
Remarks:
(none)
Inherited public predicates:
(none)

Public predicates

generate/1

Generates a random TypeID with an empty type prefix. The UUID suffix is a version 7 UUID.

Compilation flags:
static
Template:
generate(TypeID)
Mode and number of proofs:
generate(--text) - one

generate/2

Generates a random TypeID with the given type prefix. The UUID suffix is a version 7 UUID. Fails if the prefix is not valid per the TypeID specification.

Compilation flags:
static
Template:
generate(Prefix,TypeID)
Mode and number of proofs:
generate(+text,--text) - zero_or_one

generate/3

Generates a random TypeID with the given type prefix. The UUID suffix is a version 7 UUID computed using the given local UTC offset (Z or +HH:MM/-HH:MM) to convert the backend local time to UTC. Fails if the prefix is not valid per the TypeID specification.

Compilation flags:
static
Template:
generate(Prefix,Offset,TypeID)
Mode and number of proofs:
generate(+text,+atom,--text) - zero_or_one

from_uuid/3

Returns the TypeID for the given type prefix and UUID. The UUID is not required to be a version 7 UUID, allowing encoding of other UUID versions at the user discretion. Fails if the prefix is not valid per the TypeID specification or if the UUID cannot be parsed.

Compilation flags:
static
Template:
from_uuid(Prefix,UUID,TypeID)
Mode and number of proofs:
from_uuid(+text,+text,--text) - zero_or_one

to_uuid/2

Returns the UUID encoded in the suffix of the given TypeID. Fails if the TypeID is not valid per the TypeID specification.

Compilation flags:
static
Template:
to_uuid(TypeID,UUID)
Mode and number of proofs:
to_uuid(+text,--text) - zero_or_one

prefix/2

Returns the type prefix of the given TypeID. Fails if the TypeID is not valid per the TypeID specification.

Compilation flags:
static
Template:
prefix(TypeID,Prefix)
Mode and number of proofs:
prefix(+text,--text) - zero_or_one

suffix/2

Returns the base32 encoded UUID suffix of the given TypeID. Fails if the TypeID is not valid per the TypeID specification.

Compilation flags:
static
Template:
suffix(TypeID,Suffix)
Mode and number of proofs:
suffix(+text,--text) - zero_or_one

decompose/3

Decomposes a TypeID into its type prefix and its base32 encoded UUID suffix. Fails if the TypeID is not valid per the TypeID specification.

Compilation flags:
static
Template:
decompose(TypeID,Prefix,Suffix)
Mode and number of proofs:
decompose(+text,--text,--text) - zero_or_one

compose/3

Composes a TypeID from a type prefix and a base32 encoded UUID suffix. Fails if the prefix or the suffix are not valid per the TypeID specification.

Compilation flags:
static
Template:
compose(Prefix,Suffix,TypeID)
Mode and number of proofs:
compose(+text,+text,--text) - zero_or_one

valid/1

Succeeds if the given TypeID is valid per the TypeID specification.

Compilation flags:
static
Template:
valid(TypeID)
Mode and number of proofs:
valid(+text) - zero_or_one

valid_prefix/1

Succeeds if the given type prefix is valid per the TypeID specification.

Compilation flags:
static
Template:
valid_prefix(Prefix)
Mode and number of proofs:
valid_prefix(+text) - zero_or_one

valid_suffix/1

Succeeds if the given base32 encoded UUID suffix is valid per the TypeID specification.

Compilation flags:
static
Template:
valid_suffix(Suffix)
Mode and number of proofs:
valid_suffix(+text) - zero_or_one

Protected predicates

(none)

Private predicates

(none)

Operators

(none)