Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bevy_reflect: Implement Reflect support for various rand_* crates #9512

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/bevy_reflect/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ smallvec = { version = "1.6", features = [
], optional = true }
glam = { version = "0.24", features = ["serde"], optional = true }
smol_str = { version = "0.2.0", optional = true }
rand_chacha = { version = "0.3", features = ["serde1"], optional = true }
wyrand = { version = "0.1", features = ["serde1"], optional = true }
rand_pcg = { version = "0.3", features = ["serde1"], optional = true }
rand_xoshiro = { version = "0.6", features = ["serde1"], optional = true }

[dev-dependencies]
ron = "0.8.0"
Expand Down
24 changes: 24 additions & 0 deletions crates/bevy_reflect/src/impls/rand_chacha.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use crate::{self as bevy_reflect};
use crate::{ReflectDeserialize, ReflectSerialize};
use bevy_reflect_derive::impl_reflect_value;

impl_reflect_value!(::rand_chacha::ChaCha8Rng(
Debug,
PartialEq,
Serialize,
Deserialize
));

impl_reflect_value!(::rand_chacha::ChaCha12Rng(
Debug,
PartialEq,
Serialize,
Deserialize
));

impl_reflect_value!(::rand_chacha::ChaCha20Rng(
Debug,
PartialEq,
Serialize,
Deserialize
));
14 changes: 14 additions & 0 deletions crates/bevy_reflect/src/impls/rand_pcg.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use crate::{self as bevy_reflect};
use crate::{ReflectDeserialize, ReflectSerialize};
use bevy_reflect_derive::impl_reflect_value;

impl_reflect_value!(::rand_pcg::Pcg32(Debug, PartialEq, Serialize, Deserialize));

impl_reflect_value!(::rand_pcg::Pcg64(Debug, PartialEq, Serialize, Deserialize));

impl_reflect_value!(::rand_pcg::Pcg64Mcg(
Debug,
PartialEq,
Serialize,
Deserialize
));
94 changes: 94 additions & 0 deletions crates/bevy_reflect/src/impls/rand_xoshiro.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
use crate::{self as bevy_reflect};
use crate::{ReflectDeserialize, ReflectSerialize};
use bevy_reflect_derive::impl_reflect_value;

impl_reflect_value!(::rand_xoshiro::Xoshiro512StarStar(
Debug,
PartialEq,
Serialize,
Deserialize
));

impl_reflect_value!(::rand_xoshiro::Xoshiro512PlusPlus(
Debug,
PartialEq,
Serialize,
Deserialize
));

impl_reflect_value!(::rand_xoshiro::Xoshiro512Plus(
Debug,
PartialEq,
Serialize,
Deserialize
));

impl_reflect_value!(::rand_xoshiro::Xoshiro256StarStar(
Debug,
PartialEq,
Serialize,
Deserialize
));

impl_reflect_value!(::rand_xoshiro::Xoshiro256PlusPlus(
Debug,
PartialEq,
Serialize,
Deserialize
));

impl_reflect_value!(::rand_xoshiro::Xoshiro256Plus(
Debug,
PartialEq,
Serialize,
Deserialize
));

impl_reflect_value!(::rand_xoshiro::Xoshiro128StarStar(
Debug,
PartialEq,
Serialize,
Deserialize
));

impl_reflect_value!(::rand_xoshiro::Xoshiro128PlusPlus(
Debug,
PartialEq,
Serialize,
Deserialize
));

impl_reflect_value!(::rand_xoshiro::Xoshiro128Plus(
Debug,
PartialEq,
Serialize,
Deserialize
));

impl_reflect_value!(::rand_xoshiro::Xoroshiro128StarStar(
Debug,
PartialEq,
Serialize,
Deserialize
));

impl_reflect_value!(::rand_xoshiro::Xoroshiro128PlusPlus(
Debug,
PartialEq,
Serialize,
Deserialize
));

impl_reflect_value!(::rand_xoshiro::Xoroshiro128Plus(
Debug,
PartialEq,
Serialize,
Deserialize
));

impl_reflect_value!(::rand_xoshiro::SplitMix64(
Debug,
PartialEq,
Serialize,
Deserialize
));
5 changes: 5 additions & 0 deletions crates/bevy_reflect/src/impls/wyrand.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use crate::{self as bevy_reflect};
use crate::{ReflectDeserialize, ReflectSerialize};
use bevy_reflect_derive::impl_reflect_value;

impl_reflect_value!(::wyrand::WyRand(Debug, PartialEq, Serialize, Deserialize));
16 changes: 16 additions & 0 deletions crates/bevy_reflect/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,24 +484,40 @@ mod type_uuid_impl;
mod impls {
#[cfg(feature = "glam")]
mod glam;
#[cfg(feature = "rand_chacha")]
mod rand_chacha;
#[cfg(feature = "rand_pcg")]
mod rand_pcg;
#[cfg(feature = "rand_xoshiro")]
mod rand_xoshiro;
#[cfg(feature = "bevy_math")]
mod rect;
#[cfg(feature = "smallvec")]
mod smallvec;
#[cfg(feature = "smol_str")]
mod smol_str;
#[cfg(feature = "wyrand")]
mod wyrand;

mod std;
mod uuid;

#[cfg(feature = "glam")]
pub use self::glam::*;
#[cfg(feature = "rand_chacha")]
pub use self::rand_chacha::*;
#[cfg(feature = "rand_pcg")]
pub use self::rand_pcg::*;
#[cfg(feature = "rand_xoshiro")]
pub use self::rand_xoshiro::*;
#[cfg(feature = "bevy_math")]
pub use self::rect::*;
#[cfg(feature = "smallvec")]
pub use self::smallvec::*;
pub use self::std::*;
pub use self::uuid::*;
#[cfg(feature = "wyrand")]
pub use self::wyrand::*;
}

mod enums;
Expand Down