GUIDs are align(8) unless otherwise specified.
pub const Guid = extern struct
pub const Guid = extern struct {
comptime {
std.debug.assert(std.mem.Alignment.of(Guid) == .@"8");
}
time_low: u32 align(8),
time_mid: u16,
time_high_and_version: u16,
clock_seq_high_and_reserved: u8,
clock_seq_low: u8,
node: [6]u8,
/// Format GUID into hexadecimal lowercase xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format
pub fn format(self: Guid, writer: *std.Io.Writer) std.Io.Writer.Error!void {
return writer.print("{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x}", .{
self.time_low,
self.time_mid,
self.time_high_and_version,
self.clock_seq_high_and_reserved,
self.clock_seq_low,
self.node,
});
}
pub fn eql(a: Guid, b: Guid) bool {
return a.time_low == b.time_low and
a.time_mid == b.time_mid and
a.time_high_and_version == b.time_high_and_version and
a.clock_seq_high_and_reserved == b.clock_seq_high_and_reserved and
a.clock_seq_low == b.clock_seq_low and
std.mem.eql(u8, &a.node, &b.node);
}
}