Skip to content

Format API

UUID formatting functions.

Functions

FunctionSignatureDescription
encode(self: UUID, buffer: []u8) []u8Canonical lowercase
encodeUppercase(self: UUID, buffer: []u8) []u8Canonical uppercase
encodeCompact(self: UUID, buffer: []u8) []u8No dashes
encodeBraced(self: UUID, buffer: []u8) []u8Wrapped in braces
encodeUrn(self: UUID, buffer: []u8) []u8URN prefix
format(self: UUID, writer: *Io.Writer) Io.Writer.Error!voidWrite to writer
toString(self: UUID, allocator: Allocator) Allocator.Error![]u8Allocated string

Buffer Sizes

FormatBuffer Size
Canonical36 bytes
Uppercase36 bytes
Compact32 bytes
Braced38 bytes
URN45 bytes

Validation

Use uuid.isValid(input) to check if a string is a valid UUID format without parsing:

zig
if (uuid.isValid("550e8400-e29b-41d4-a716-446655440000")) {
    // Valid format
}

Supports all formats: canonical, compact, braced, and URN.

Released under the MIT License.