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