Skip to content

Generator API

Allocator-aware wrapper for UUID operations.

Definition

zig
pub const Generator = struct {
    allocator: Allocator,
    io: Io,
    // ...
};

Methods

MethodSignatureDescription
init(allocator: Allocator, io: Io) GeneratorCreate generator
v1(self, timestamp: u60, clock_seq: u14, node: [6]u8) UUIDGenerate v1
v3(self, namespace: UUID, name: []const u8) UUIDGenerate v3
v4(self) Io.RandomSecureError!UUIDGenerate v4
v5(self, namespace: UUID, name: []const u8) UUIDGenerate v5
v6(self, timestamp: u60, clock_seq: u14, node: [6]u8) UUIDGenerate v6
v7(self) Io.RandomSecureError!UUIDGenerate v7
v7WithTimestamp(self, timestamp_ms: u48, rand_a: u12, rand_b: [10]u8) UUIDGenerate v7 with custom timestamp
v8(self, custom: [16]u8) UUIDGenerate v8
toString(self, uuid: UUID) Allocator.Error![]u8UUID to string

Example

zig
const gen = uuid.Generator.init(allocator, io);
const id = try gen.v4();
const str = try gen.toString(id);
defer allocator.free(str);

Released under the MIT License.