uuid
The uuid module implements RFC 9562-compatible Univerally Unique IDentifiers.
This module only generates UUID4, aka "truly random" UUIDs, due to privacy concerns.
Index
Types
type uuid = [16]u8;
Errors
type invalid = !void;
Constants
def UUID_LEN: size = 16;
def UUID_STRLEN: size = 36;
def UUID_URILEN: size = 45;
Globals
const nil: uuid;
Functions
fn compare(a: uuid, b: uuid) bool;
fn decode(in: io::handle) (uuid | invalid | io::error);
fn decodestr(in: str) (uuid | invalid);
fn encode(out: io::handle, in: uuid) (size | io::error);
fn encodestr(in: uuid) str;
fn encodeuri(in: uuid) str;
fn generate() uuid;
fn uri(out: io::handle, in: uuid) (size | io::error);
Types
type uuid
type uuid = [16]u8;
A UUID.
Errors
type invalid
type invalid = !void;
Returned from decode if an invalid UUID is observed.
Constants
def UUID_LEN
def UUID_LEN: size = 16;
The length of a UUID in bytes.
def UUID_STRLEN
def UUID_STRLEN: size = 36;
The length of a UUID in runes when encoded as a string.
def UUID_URILEN
def UUID_URILEN: size = 45;
The length of the return value of uri in runes.
Globals
let nil
const nil: uuid;
The "nil" UUID, with all bits set to zero.
Functions
fn compare
fn compare(a: uuid, b: uuid) bool;
Returns true if two UUIDs are equal.
fn decode
fn decode(in: io::handle) (uuid | invalid | io::error);
Decodes a UUID as a string from an io::handle.
fn decodestr
fn decodestr(in: str) (uuid | invalid);
Decodes a UUID from a string.
fn encode
fn encode(out: io::handle, in: uuid) (size | io::error);
Encodes a UUID as a string and writes it to an I/O handle.
fn encodestr
fn encodestr(in: uuid) str;
Encodes a UUID as a string. The return value is statically allocated, the caller must use strings::dup to extend its lifetime.
fn encodeuri
fn encodeuri(in: uuid) str;
Encodes a UUID as a string. The return value is statically allocated, the caller must use strings::dup to extend its lifetime.
fn generate
fn generate() uuid;
Generates a new version 4 UUID.
fn uri
fn uri(out: io::handle, in: uuid) (size | io::error);
Encodes a UUID as a URI and writes it to an I/O handle.