Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/getrandom/src/wasi.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / getrandom / src / wasi.rs` 17 lines ยท 541 bytes Raw Blame History 1 //! Implementation for WASI 2 use crate::Error; 3 use core::{ 4 mem::MaybeUninit, 5 num::{NonZeroU16, NonZeroU32}, 6 }; 7 use wasi::random_get; 8 9 pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { 10 unsafe { random_get(dest.as_mut_ptr() as *mut u8, dest.len()) }.map_err(|e| { 11 // The WASI errno will always be non-zero, but we check just in case. 12 match NonZeroU16::new(e.raw()) { 13 Some(r) => Error::from(NonZeroU32::from(r)), 14 None => Error::ERRNO_NOT_POSITIVE, 15 } 16 }) 17 }