1#[cfg(feature = "v4")]
2pub(crate) fn bytes() -> [u8; 16] {
3 #[cfg(not(feature = "fast-rng"))]
4 {
5 let mut bytes = [0u8; 16];
6
7 private_getrandom::getrandom(&mut bytes).unwrap_or_else(|err| {
8 panic!("could not retrieve random bytes for uuid: {}", err)
10 });
11
12 bytes
13 }
14
15 #[cfg(feature = "fast-rng")]
16 {
17 private_rand::random()
18 }
19}
20
21#[cfg(feature = "v1")]
22pub(crate) fn u16() -> u16 {
23 #[cfg(not(feature = "fast-rng"))]
24 {
25 let mut bytes = [0u8; 2];
26
27 private_getrandom::getrandom(&mut bytes).unwrap_or_else(|err| {
28 panic!("could not retrieve random bytes for uuid: {}", err)
30 });
31
32 ((bytes[0] as u16) << 8) | (bytes[1] as u16)
33 }
34
35 #[cfg(feature = "fast-rng")]
36 {
37 private_rand::random()
38 }
39}