proxy-sdk 1.1.0

Write extensions for Proxy-WASM for WASM or Native environments
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use std::num::NonZeroU32;

fn proxywasm_getrandom(buf: &mut [u8]) -> Result<(), getrandom::Error> {
    if let Err(Some(e)) = unsafe { wasi::random_get(buf.as_mut_ptr(), buf.len()) }
        .map_err(|e| NonZeroU32::new(e.raw() as u32))
    {
        Err(e.into())
    } else {
        Ok(())
    }
}

getrandom::register_custom_getrandom!(proxywasm_getrandom);