Expand description
§Bevy PRNG
§What is Bevy PRNG?
bevy_prng is a crate that provides newtyped versions of various rand_* PRNG algorithm crates to make them suitable for integration within bevy for reflection purposes. It enables these types to have stable TypePaths and otherwise implement various required traits. This crate can be used as standalone to provide access to various PRNG algorithms of one’s choice, to then use to write components/resources for one’s game in bevy, but primarily, it’s purpose to support and be a counterpart to bevy_rand (which provides the generic wrapper component/resource that bevy_prng types can plug in to).
§Using Bevy PRNG
By default, bevy_prng won’t export anything unless the feature/algorithm you require is explicitly defined. In order to gain access to a newtyped PRNG struct, you’ll have activate one of the following features:
rand_chacha- This enables the exporting of newtypedChaCha*Rngstructs, for those that want/need to use a CSPRNG level source.rand_pcg- This enables the exporting of newtypedPcg*structs fromrand_pcg.rand_xoshiro- This enables the exporting of newtypedXoshiro*structs fromrand_xoshiro. It also reexportsSeed512so to allow setting upXoshiro512StarStarand so forth without the need to pull inrand_xoshiroexplicitly.wyrand- This enables the exporting of newtypedWyRandfromwyrand, the same algorithm in use withinfastrand/turborand.
In addition to these feature flags to enable various supported algorithms, there’s also serialize flag to provide serde support for Serialize/Deserialize, which is enabled by default.
All types are provided at the top-level of the module:
use bevy_prng::*;§Supported PRNG Algorithms/Crates
All the below crates implement the necessary traits to be compatible with bevy_prng. Additional PRNG crates can be added via PR’s to this crate/repo, provided the PRNGs implement Debug, Clone, PartialEq and have optional Serialize/Deserialize serde traits implemented and put behind appropriate feature flags.
§Cryptographically Secure PRNGs
§Non-Cryptographically Secure PRNGS
§Supported Versions & MSRV
bevy_prng uses the same MSRV as bevy.
bevy | bevy_prng |
|---|---|
| v0.13 | v0.5 |
| v0.12 | v0.2 |
| v0.11 | v0.1 |
The versions of rand_core/rand that bevy_prng is compatible with is as follows:
bevy_prng | rand_core | rand |
|---|---|---|
| v0.1 -> v0.5 | v0.6 | v0.8 |
§License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Structs§
- ChaCha8Rng
rand_chachaA newtypedrand_chacha::ChaCha8RngRNG - ChaCha12Rng
rand_chachaA newtypedrand_chacha::ChaCha12RngRNG - ChaCha20Rng
rand_chachaA newtypedrand_chacha::ChaCha20RngRNG - Pcg32
rand_pcgA newtypedrand_pcg::Pcg32RNG - Pcg64
rand_pcgA newtypedrand_pcg::Pcg64RNG - Pcg64Mcg
rand_pcgA newtypedrand_pcg::Pcg64McgRNG - Seed512
rand_xoshiro512-bit seed for a generator. - A newtyped
wyrand::WyRandRNG - Xoroshiro64Star
rand_xoshiroA newtypedrand_xoshiro::Xoroshiro64StarRNG - Xoroshiro64StarStar
rand_xoshiroA newtypedrand_xoshiro::Xoroshiro64StarStarRNG - Xoroshiro128Plus
rand_xoshiroA newtypedrand_xoshiro::Xoshiro128PlusRNG - Xoroshiro128PlusPlus
rand_xoshiroA newtypedrand_xoshiro::Xoshiro256PlusPlusRNG - Xoroshiro128StarStar
rand_xoshiroA newtypedrand_xoshiro::Xoshiro128StarStarRNG - Xoshiro128Plus
rand_xoshiroA newtypedrand_xoshiro::Xoshiro128PlusRNG - Xoshiro128PlusPlus
rand_xoshiroA newtypedrand_xoshiro::Xoshiro256PlusPlusRNG - Xoshiro128StarStar
rand_xoshiroA newtypedrand_xoshiro::Xoshiro128StarStarRNG - Xoshiro256Plus
rand_xoshiroA newtypedrand_xoshiro::Xoshiro256PlusRNG - Xoshiro256PlusPlus
rand_xoshiroA newtypedrand_xoshiro::Xoshiro256PlusPlusRNG - Xoshiro256StarStar
rand_xoshiroA newtypedrand_xoshiro::Xoshiro256StarStarRNG - Xoshiro512Plus
rand_xoshiroA newtypedrand_xoshiro::Xoshiro512PlusRNG - Xoshiro512PlusPlus
rand_xoshiroA newtypedrand_xoshiro::Xoshiro512PlusPlusRNG - Xoshiro512StarStar
rand_xoshiroA newtypedrand_xoshiro::Xoshiro512StarStarRNG
Traits§
- A marker trait to define the required trait bounds for a seedable PRNG to integrate into
EntropyComponentorGlobalEntropy. This is a sealed trait.