(mut buf: Buf, flags: GetRandomFlags)
| 26 | /// [Linux]: https://man7.org/linux/man-pages/man2/getrandom.2.html |
| 27 | #[inline] |
| 28 | pub fn getrandom<Buf: Buffer<u8>>(mut buf: Buf, flags: GetRandomFlags) -> io::Result<Buf::Output> { |
| 29 | // SAFETY: `getrandom` behaves. |
| 30 | let len = unsafe { backend::rand::syscalls::getrandom(buf.parts_mut(), flags)? }; |
| 31 | // SAFETY: `getrandom` behaves. |
| 32 | unsafe { Ok(buf.assume_init(len)) } |
| 33 | } |