MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / getrandom

Function getrandom

src/rand/getrandom.rs:28–33  ·  view source on GitHub ↗
(mut buf: Buf, flags: GetRandomFlags)

Source from the content-addressed store, hash-verified

26/// [Linux]: https://man7.org/linux/man-pages/man2/getrandom.2.html
27#[inline]
28pub 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}

Callers 2

test_getrandomFunction · 0.50
test_getrandom_uninitFunction · 0.50

Calls 2

parts_mutMethod · 0.80
assume_initMethod · 0.80

Tested by 2

test_getrandomFunction · 0.40
test_getrandom_uninitFunction · 0.40