9 releases (5 breaking)

0.8.0 Nov 30, 2024
0.7.1 Jul 5, 2024
0.6.0 Apr 24, 2024
0.5.2 Feb 21, 2024
0.1.0 Aug 29, 2023

#1826 in Game dev

Download history 120/week @ 2024-08-17 101/week @ 2024-08-24 123/week @ 2024-08-31 130/week @ 2024-09-07 140/week @ 2024-09-14 174/week @ 2024-09-21 158/week @ 2024-09-28 68/week @ 2024-10-05 160/week @ 2024-10-12 159/week @ 2024-10-19 84/week @ 2024-10-26 154/week @ 2024-11-02 58/week @ 2024-11-09 553/week @ 2024-11-16 172/week @ 2024-11-23 257/week @ 2024-11-30

1,068 downloads per month
Used in 2 crates (via bevy_rand)

MIT/Apache

19KB
424 lines

Bevy PRNG

Crates.io CI License Documentation

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 newtyped ChaCha*Rng structs, for those that want/need to use a CSPRNG level source.
  • rand_pcg - This enables the exporting of newtyped Pcg* structs from rand_pcg.
  • rand_xoshiro - This enables the exporting of newtyped Xoshiro* structs from rand_xoshiro. It also exports a remote-reflected version of Seed512 so to allow setting up Xoshiro512StarStar and so forth.
  • wyrand - This enables the exporting of newtyped WyRand from wyrand, the same algorithm in use within fastrand/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.15 v0.8
v0.14 v0.7 -> v0.8
v0.13 v0.5 -> v0.6
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.8 v0.6 v0.8

License

Licensed under either of

at your option.

Dependencies

~6.5MB
~117K SLoC