.. index:: single: uuid_protocol
.. _uuid_protocol/0:

.. rst-class:: right

**protocol**

``uuid_protocol``
=================

Universally unique identifier (UUID) generator protocol.

| **Availability:** 
|    ``logtalk_load(uuid(loader))``

| **Author:** Paulo Moura
| **Version:** 1:0:0
| **Date:** 2026-07-06

| **Compilation flags:**
|    ``static``


| **Dependencies:**
|   (none)


| **Remarks:**
|    (none)

| **Inherited public predicates:**
|    (none)

.. contents::
   :local:
   :backlinks: top

Public predicates
-----------------

.. index:: uuid_v1/2
.. _uuid_protocol/0::uuid_v1/2:

``uuid_v1/2``
^^^^^^^^^^^^^

Returns a version 1 UUID for the given MAC address (a list of six bytes). The MAC address can be replaced by a random 6 bytes node identifier as per RFC 4122 when the MAC address is not available or should not be disclosed. Portability note: some backends only provide access to local time; use ``uuid_v1/3`` with an explicit UTC offset when a UTC timestamp is required.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``uuid_v1(MAC,UUID)``
| **Mode and number of proofs:**
|    ``uuid_v1(+list(byte),--text)`` - ``one``


------------

.. index:: uuid_v1/3
.. _uuid_protocol/0::uuid_v1/3:

``uuid_v1/3``
^^^^^^^^^^^^^

Returns a version 1 UUID for the given MAC address (a list of six bytes) using the given local UTC offset (``Z`` or ``+HH:MM``/``-HH:MM``) to convert the backend local time to UTC. The MAC address can be replaced by a random 6 bytes node identifier as per RFC 4122 when the MAC address is not available or should not be disclosed.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``uuid_v1(MAC,Offset,UUID)``
| **Mode and number of proofs:**
|    ``uuid_v1(+list(byte),+atom,--text)`` - ``zero_or_one``


------------

.. index:: uuid_v3/3
.. _uuid_protocol/0::uuid_v3/3:

``uuid_v3/3``
^^^^^^^^^^^^^

Returns a version 3 UUID for the given namespace UUID and name. Namespace UUIDs and names can be represented as atoms, lists of characters, or lists of character codes. Name character codes must be bytes.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``uuid_v3(Namespace,Name,UUID)``
| **Mode and number of proofs:**
|    ``uuid_v3(+text,+text,--text)`` - ``one``


------------

.. index:: uuid_v4/1
.. _uuid_protocol/0::uuid_v4/1:

``uuid_v4/1``
^^^^^^^^^^^^^

Returns a version 4 UUID.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``uuid_v4(UUID)``
| **Mode and number of proofs:**
|    ``uuid_v4(--text)`` - ``one``


------------

.. index:: uuid_v5/3
.. _uuid_protocol/0::uuid_v5/3:

``uuid_v5/3``
^^^^^^^^^^^^^

Returns a version 5 UUID for the given namespace UUID and name. Namespace UUIDs and names can be represented as atoms, lists of characters, or lists of character codes. Name character codes must be bytes.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``uuid_v5(Namespace,Name,UUID)``
| **Mode and number of proofs:**
|    ``uuid_v5(+text,+text,--text)`` - ``one``


------------

.. index:: uuid_v7/1
.. _uuid_protocol/0::uuid_v7/1:

``uuid_v7/1``
^^^^^^^^^^^^^

Returns a version 7 UUID. Portability note: some backends only provide access to local time; use ``uuid_v7/2`` with an explicit UTC offset when a UTC timestamp is required.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``uuid_v7(UUID)``
| **Mode and number of proofs:**
|    ``uuid_v7(--text)`` - ``one``


------------

.. index:: uuid_v7/2
.. _uuid_protocol/0::uuid_v7/2:

``uuid_v7/2``
^^^^^^^^^^^^^

Returns a version 7 UUID using the given local UTC offset (``Z`` or ``+HH:MM``/``-HH:MM``) to convert the backend local time to UTC.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``uuid_v7(Offset,UUID)``
| **Mode and number of proofs:**
|    ``uuid_v7(+atom,--text)`` - ``zero_or_one``


------------

.. index:: uuid_null/1
.. _uuid_protocol/0::uuid_null/1:

``uuid_null/1``
^^^^^^^^^^^^^^^

Returns the null UUID. Deprecated. Use ``uuid_nil/1`` instead.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``uuid_null(UUID)``
| **Mode and number of proofs:**
|    ``uuid_null(--text)`` - ``one``


------------

.. index:: uuid_nil/1
.. _uuid_protocol/0::uuid_nil/1:

``uuid_nil/1``
^^^^^^^^^^^^^^

Returns the Nil UUID.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``uuid_nil(UUID)``
| **Mode and number of proofs:**
|    ``uuid_nil(--text)`` - ``one``


------------

.. index:: uuid_max/1
.. _uuid_protocol/0::uuid_max/1:

``uuid_max/1``
^^^^^^^^^^^^^^

Returns the Max UUID.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``uuid_max(UUID)``
| **Mode and number of proofs:**
|    ``uuid_max(--text)`` - ``one``


------------

.. index:: random_node/1
.. _uuid_protocol/0::random_node/1:

``random_node/1``
^^^^^^^^^^^^^^^^^

Generates a list with six random bytes that can be used in alternative to a MAC address when generating version 1 UUIDs.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``random_node(Node)``
| **Mode and number of proofs:**
|    ``random_node(--list(byte))`` - ``one``


------------

Protected predicates
--------------------

(none)

Private predicates
------------------

(none)

Operators
---------

(none)

