rrchelbi/uuiz
Because every identity deserves a unique one. 🆔
uuiz - Because every identity deserves a unique one. 🆔
A lightweight, zero-dependency UUID library for Zig. Provides RFC 4122 compliant UUID generation, parsing, and manipulation with a focus on performance and type safety.
$ zig fetch --save git+https://www.github.com/rrchelbi/uuiz#main
After this your build.zig.zon
should look like this:
.{
// other attributes
// ...
.dependencies = .{
// other dependencies
// ...
.uuiz = .{
.url = "https://github.com/rrchelbi/uuiz?ref=main#...",
.hash = "1220...",
},
},
}
build.zig
:const uuiz = b.dependency("uuiz", .{
.target = target,
.optimize = optimize,
});
exe.addModule("uuiz", uuiz.module("uuiz"));
const std = @import("std");
const uuiz = @import("uuiz");
pub fn main() !void {
const uuid = uuiz.v4.new();
std.debug.print("Generated v4 UUID: {}\n", .{uuid});
}
// Main UUID type (128 bits)
const UUID = u128;
// UUID versions
const Version = enum {
V1, // Time-based
V2, // DCE Security
V3, // MD5 hash
V4, // Random
V5, // SHA-1 hash
V6, // Ordered time-based
V7, // Unix timestamp-based
V8, // Custom
};
// Layout struct for direct field access
// This struct is not DoD yet, more work needed!
const Layout = struct {
clock_seq_hi_and_res: u8,
clock_seq_low: u8,
time_mid: u16,
time_hi_and_version: u16,
time_low: u32,
node: u48,
};
Version | Status | Description |
---|---|---|
v1 | Time-based with MAC address | |
v2 | DCE Security | |
v3 | MD5 namespace-based | |
v4 | ✅ | Random (cryptographically secure) |
v5 | SHA-1 namespace-based | |
v6 | Ordered time-based | |
v7 | Unix timestamp-based | |
v8 | Custom format |
git checkout -b feature/amazing-feature
)git commit -m 'Add amazing feature'
)git push origin feature/amazing-feature
)This project is licensed under the MIT License - see the LICENSE file for details.