extern struct Guid [src]
GUIDs are align(8) unless otherwise specified.
Fields
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
Members
Source
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 {
const time_low = @byteSwap(self.time_low);
const time_mid = @byteSwap(self.time_mid);
const time_high_and_version = @byteSwap(self.time_high_and_version);
return writer.print("{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x:0>12}", .{
std.mem.asBytes(&time_low),
std.mem.asBytes(&time_mid),
std.mem.asBytes(&time_high_and_version),
std.mem.asBytes(&self.clock_seq_high_and_reserved),
std.mem.asBytes(&self.clock_seq_low),
std.mem.asBytes(&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);
}
}