Add Uuid.randV4
This commit is contained in:
parent
c484af6179
commit
b140b20298
1 changed files with 11 additions and 0 deletions
11
src/util.zig
11
src/util.zig
|
@ -55,6 +55,17 @@ pub const Uuid = struct {
|
|||
|
||||
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 {
|
||||
|
|
Loading…
Reference in a new issue