/rust/registry/src/index.crates.io-6f17d22bba15001f/uuid-1.8.0/src/rng.rs
Line | Count | Source (jump to first uncovered line) |
1 | | #[cfg(any(feature = "v4", feature = "v7"))] |
2 | 0 | pub(crate) fn bytes() -> [u8; 16] { |
3 | 0 | #[cfg(not(feature = "fast-rng"))] |
4 | 0 | { |
5 | 0 | let mut bytes = [0u8; 16]; |
6 | 0 |
|
7 | 0 | getrandom::getrandom(&mut bytes).unwrap_or_else(|err| { |
8 | 0 | // NB: getrandom::Error has no source; this is adequate display |
9 | 0 | panic!("could not retrieve random bytes for uuid: {}", err) |
10 | 0 | }); |
11 | 0 |
|
12 | 0 | bytes |
13 | 0 | } |
14 | 0 |
|
15 | 0 | #[cfg(feature = "fast-rng")] |
16 | 0 | { |
17 | 0 | rand::random() |
18 | 0 | } |
19 | 0 | } |
20 | | |
21 | | #[cfg(any(feature = "v1", feature = "v6"))] |
22 | | pub(crate) fn u16() -> u16 { |
23 | | #[cfg(not(feature = "fast-rng"))] |
24 | | { |
25 | | let mut bytes = [0u8; 2]; |
26 | | |
27 | | getrandom::getrandom(&mut bytes).unwrap_or_else(|err| { |
28 | | // NB: getrandom::Error has no source; this is adequate display |
29 | | 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 | | rand::random() |
38 | | } |
39 | | } |