[package] name = "getrandom" version = "0.4.3" edition = "2024" rust-version = "1.85" # Sync tests.yml and README.md. authors = ["The Rand Project Developers"] license = "MIT OR Apache-2.0" description = "A small cross-platform library for retrieving random data from system source" documentation = "https://docs.rs/getrandom" repository = "https://github.com/rust-random/getrandom" categories = ["os", "no-std"] exclude = [".*"] [package.metadata.docs.rs] features = ["std", "sys_rng"] rustdoc-args = ["--cfg", "getrandom_backend=\"extern_impl\""] [features] # Implement From for std::io::Error and # use std to retrieve OS error descriptions std = [] # Optional backend: wasm_js # # This flag enables the wasm_js backend and uses it by default on wasm32 where # the target_os is unknown. The getrandom_backend cfg may override this. # # WARNING: We strongly recommend against enabling this feature in libraries (except for tests) # since it is known to break non-Web WASM builds and further since the usage of `wasm-bindgen` # causes significant bloat to `Cargo.lock` (on all targets). # # The only exception to this rule: if your crate already unconditionally depends on `wasm-bindgen` # or `js-sys` on "unknown" WASM targets then it's acceptable to enable this feature unconditionally. wasm_js = ["dep:wasm-bindgen", "dep:js-sys"] # Provide SysRng over rand_core sys_rng = ["dep:rand_core"] [dependencies] cfg-if = "1" rand_core = { version = "0.10.0", optional = true } # getrandom / linux_android_with_fallback [target.'cfg(all(any(target_os = "linux", target_os = "android"), not(any(all(target_os = "linux", target_env = ""), getrandom_backend = "custom", getrandom_backend = "linux_raw", getrandom_backend = "rdrand", getrandom_backend = "rndr"))))'.dependencies] libc = { version = "0.2.154", default-features = false } # apple-other [target.'cfg(any(target_os = "ios", target_os = "visionos", target_os = "watchos", target_os = "tvos"))'.dependencies] libc = { version = "0.2.154", default-features = false } # efi_rng [target.'cfg(all(target_os = "uefi", getrandom_backend = "efi_rng"))'.dependencies] r-efi = { version = "6", default-features = false } # getentropy [target.'cfg(any(target_os = "macos", target_os = "openbsd", target_os = "vita", target_os = "emscripten"))'.dependencies] libc = { version = "0.2.154", default-features = false } # getrandom [target.'cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "hurd", target_os = "illumos", target_os = "cygwin", all(target_os = "horizon", target_arch = "arm")))'.dependencies] libc = { version = "0.2.154", default-features = false } # netbsd [target.'cfg(target_os = "netbsd")'.dependencies] libc = { version = "0.2.154", default-features = false } # solaris [target.'cfg(target_os = "solaris")'.dependencies] libc = { version = "0.2.154", default-features = false } # use_file [target.'cfg(any(target_os = "haiku", target_os = "redox", target_os = "nto", target_os = "aix"))'.dependencies] libc = { version = "0.2.154", default-features = false } # vxworks [target.'cfg(target_os = "vxworks")'.dependencies] libc = { version = "0.2.154", default-features = false } # wasm_js [target.'cfg(all(target_family = "wasm", any(target_os = "unknown", target_os = "none")))'.dependencies] wasm-bindgen = { version = "0.2.98", default-features = false, optional = true } [target.'cfg(all(target_family = "wasm", any(target_os = "unknown", target_os = "none"), target_feature = "atomics"))'.dependencies] js-sys = { version = "0.3.77", default-features = false, optional = true } [target.'cfg(all(target_family = "wasm", any(target_os = "unknown", target_os = "none")))'.dev-dependencies] wasm-bindgen-test = "0.3" [lints.rust.unexpected_cfgs] level = "warn" check-cfg = [ 'cfg(getrandom_backend, values("custom", "efi_rng", "rdrand", "rndr", "linux_getrandom", "linux_raw", "windows_legacy", "unsupported", "extern_impl"))', 'cfg(getrandom_msan)', 'cfg(getrandom_test_linux_fallback)', 'cfg(getrandom_test_linux_without_fallback)', 'cfg(getrandom_test_netbsd_fallback)', 'cfg(target_os, values("cygwin"))', # TODO(MSRV 1.86): Remove this. 'cfg(target_os, values("motor"))', ] [lints.rust] unused_lifetimes = "warn" missing_docs = "warn" [lints.clippy] cast_lossless = "warn" cast_possible_truncation = "warn" cast_possible_wrap = "warn" cast_precision_loss = "warn" cast_ptr_alignment = "warn" cast_sign_loss = "warn" char_lit_as_u8 = "warn" checked_conversions = "warn" fn_to_numeric_cast = "warn" fn_to_numeric_cast_with_truncation = "warn" ptr_as_ptr = "warn" unnecessary_cast = "warn" useless_conversion = "warn" # workaround for https://github.com/cross-rs/cross/issues/1345 [package.metadata.cross.target.x86_64-unknown-netbsd] pre-build = [ "mkdir -p /tmp/netbsd", "curl -fO https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.3/amd64/binary/sets/base.tar.xz", "tar -C /tmp/netbsd -xJf base.tar.xz", "cp /tmp/netbsd/usr/lib/libexecinfo.so /usr/local/x86_64-unknown-netbsd/lib", "rm base.tar.xz", "rm -rf /tmp/netbsd", ]