* Cleanup wasm32-wasi target This change ensures that we only compile our WASI implementation for 32-bit targets. The interaction between the WASI proposal and the memory64 proposal is not yet clear, [wasmtime does not yet support]( https://github.com/bytecodealliance/wasmtime/issues/3594#issuecomment-992590383) using WASI with memory64, and many of the interfaces use 32-bit values for pointers. This change also reduces the use of `unsafe` from the wasi implementation. As noted in #253, changes to `Errno` mean that we can't get the error message from the raw error code, but we can avoid using unsafe when converting this code to a NonZeroU32. This handling also makes WASI behave more like our other targets, which also manually check that errno is non-zero. Signed-off-by: Joe Richey <joerichey@google.com> * Disable default features for WASI crate Similar to this crate, the `wasi` crate just uses a `std` feature to implement `std::error::Errno`, which we don't use. Signed-off-by: Joe Richey <joerichey@google.com> Signed-off-by: Joe Richey <joerichey@google.com>
getrandom
A Rust library for retrieving random data from (operating) system source. It is
assumed that system always provides high-quality cryptographically secure random
data, ideally backed by hardware entropy sources. This crate derives its name
from Linux's getrandom function, but is cross platform, roughly supporting
the same set of platforms as Rust's std lib.
This is a low-level API. Most users should prefer using high-level random-number
library like rand.
Usage
Add this to your Cargo.toml:
[dependencies]
getrandom = "0.2"
Then invoke the getrandom function:
fn get_random_buf() -> Result<[u8; 32], getrandom::Error> {
let mut buf = [0u8; 32];
getrandom::getrandom(&mut buf)?;
Ok(buf)
}
For more information about supported targets, entropy sources, no_std targets,
crate features, WASM support and Custom RNGs see the
getrandom documentation and
getrandom::Error documentation.
Minimum Supported Rust Version
This crate requires Rust 1.36.0 or later.
License
The getrandom library is distributed under either of
at your option.