• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use crate::{backend, io};
2 
3 /// `GRND_*`
4 pub use backend::rand::types::GetRandomFlags;
5 
6 /// `getrandom(buf, flags)`—Reads a sequence of random bytes.
7 ///
8 /// This is a very low-level API which may be difficult to use correctly. Most
9 /// users should prefer to use [`getrandom`] or [`rand`] APIs instead.
10 ///
11 /// [`getrandom`]: https://crates.io/crates/getrandom
12 /// [`rand`]: https://crates.io/crates/rand
13 ///
14 /// # References
15 ///  - [Linux]
16 ///
17 /// [Linux]: https://man7.org/linux/man-pages/man2/getrandom.2.html
18 #[inline]
getrandom(buf: &mut [u8], flags: GetRandomFlags) -> io::Result<usize>19 pub fn getrandom(buf: &mut [u8], flags: GetRandomFlags) -> io::Result<usize> {
20     backend::rand::syscalls::getrandom(buf, flags)
21 }
22