@std/data/uuid.ms#
Import each required symbol with import Name from "@std/data/uuid.ms".
namespace_dns Constant#
The namespace for fully qualified domain names, for uuid_v5.
namespace_dns Stringnamespace_oid Constant#
The namespace for ISO object identifiers, for uuid_v5.
namespace_oid Stringnamespace_url Constant#
The namespace for URLs, for uuid_v5.
namespace_url Stringnamespace_x500 Constant#
The namespace for X.500 distinguished names, for uuid_v5.
namespace_x500 Stringuuid_v4 Function#
Creates a random version-4 UUID in lowercase text from the operating system’s
entropy. Entropy failures return an Error.
fn uuid_v4() Result[String, Error] { ... }uuid_v5 Function#
Creates the version-5 (SHA-1, name-based) UUID of name within namespace.
The same namespace and name always give the same lowercase UUID, so it makes a stable id for a URL, a path or a key.
namespace is any UUID text, such as namespace_url or an application’s own UUID; malformed text returns an Error with kind EBADMSG.
Example: uuid_v5(namespace_dns, "python.org") is "886313e1-3b8a-5372-9b90-0c9aee199e5d".
fn uuid_v5(namespace String, name String) Result[String, Error] { ... }uuid_v7 Function#
Creates a version-7 UUID: the current Unix time in milliseconds, a 12-bit sequence, then random bits, in lowercase text.
Ids made later sort after ids made earlier as strings, which keeps database indexes and logs in creation order.
Ids made in the same millisecond, even by different tasks, are ordered by the sequence, which counts up from a random start; if the sequence fills up or the clock steps back, the timestamp field keeps counting forward instead. Entropy failures return an Error.
fn uuid_v7() Result[String, Error] { ... }uuid_version Function#
Returns the version digit (1 through 8) of a UUID text, or null when text is not an
RFC 9562 UUID (including malformed text). Case does not matter. Example:
uuid_version("886313e1-3b8a-5372-9b90-0c9aee199e5d") is 5.
fn uuid_version(text String) Int? { ... }