]> git.proxmox.com Git - rustc.git/blob - vendor/rustix/src/rand/getrandom.rs
New upstream version 1.64.0+dfsg1
[rustc.git] / vendor / rustix / src / rand / getrandom.rs
1 use crate::{imp, io};
2
3 /// `GRND_*`
4 pub use imp::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]
19 pub fn getrandom(buf: &mut [u8], flags: GetRandomFlags) -> io::Result<usize> {
20 imp::rand::syscalls::getrandom(buf, flags)
21 }