diff options
Diffstat (limited to 'vendor/rustix/src/rand')
-rw-r--r-- | vendor/rustix/src/rand/getrandom.rs | 20 | ||||
-rw-r--r-- | vendor/rustix/src/rand/mod.rs | 7 |
2 files changed, 27 insertions, 0 deletions
diff --git a/vendor/rustix/src/rand/getrandom.rs b/vendor/rustix/src/rand/getrandom.rs new file mode 100644 index 0000000..3fed0dd --- /dev/null +++ b/vendor/rustix/src/rand/getrandom.rs @@ -0,0 +1,20 @@ +use crate::{backend, io}; + +pub use backend::rand::types::GetRandomFlags; + +/// `getrandom(buf, flags)`—Reads a sequence of random bytes. +/// +/// This is a very low-level API which may be difficult to use correctly. Most +/// users should prefer to use [`getrandom`] or [`rand`] APIs instead. +/// +/// [`getrandom`]: https://crates.io/crates/getrandom +/// [`rand`]: https://crates.io/crates/rand +/// +/// # References +/// - [Linux] +/// +/// [Linux]: https://man7.org/linux/man-pages/man2/getrandom.2.html +#[inline] +pub fn getrandom(buf: &mut [u8], flags: GetRandomFlags) -> io::Result<usize> { + backend::rand::syscalls::getrandom(buf, flags) +} diff --git a/vendor/rustix/src/rand/mod.rs b/vendor/rustix/src/rand/mod.rs new file mode 100644 index 0000000..e767c59 --- /dev/null +++ b/vendor/rustix/src/rand/mod.rs @@ -0,0 +1,7 @@ +//! Random-related operations. + +#[cfg(linux_kernel)] +mod getrandom; + +#[cfg(linux_kernel)] +pub use getrandom::{getrandom, GetRandomFlags}; |