Add Uuid.randV4

This commit is contained in:
jaina heartles 2022-05-12 20:27:42 -07:00
parent c484af6179
commit b140b20298

View file

@ -55,6 +55,17 @@ pub const Uuid = struct {
return uuid; return uuid;
} }
pub fn randV4(rand: std.rand.Random) Uuid {
var ret: Uuid = undefined;
rand.bytes(&ret.data);
// signify that this is a random v4 uuid
ret.data[7] = (0b0100_0000) | (ret.data[7] & 0b1111);
ret.data[9] = (0b1000_0000) | (ret.data[9] & 0b11_1111);
return ret;
}
}; };
pub const ciutf8 = struct { pub const ciutf8 = struct {