### Rng Example: Default Initialization Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/prelude/struct.Rng An example demonstrating the usage of `Rng::default()`. It shows that two independently created default Rng instances produce different random numbers, confirming non-deterministic seeding. ```rust use turborand::prelude::*; let rng1 = Rng::default(); let rng2 = Rng::default(); assert_ne!(rng1.u64(..), rng2.u64(..)); ``` -------------------------------- ### Example: Using GlobalChaChaRng for Random Actions (Rust) Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/struct.GlobalChaChaRng_search= Demonstrates how to use GlobalChaChaRng within a Bevy system to perform random actions. It shows how to get a mutable reference to the RNG and use it with iterators for generating and filtering random values. This requires Bevy and bevy_turborand to be set up. ```rust use bevy::prelude::*; use bevy_turborand::prelude::*; use std::iter::repeat_with; fn contrived_random_actions(mut rand: ResMut) { let rand = rand.get_mut(); // Important to shadow the rand mut reference into being an immutable `TurboRand` one. // Now the `TurboRand` instance can be borrowed in multiple places in the iterator without issue. let output: Vec = repeat_with(|| rand.f64()).take(5).filter(|&val| rand.chance(val)).collect(); println!("Received random values: {:?}", output); } ``` -------------------------------- ### Example: Generating Random Bytes with GenCore Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/prelude/trait.GenCore Demonstrates how to use the `gen` method from the GenCore trait to generate an array of random bytes. This example requires the `turborand::prelude::*` import and an initialized `Rng` instance. ```rust use turborand::prelude::*; let rand = Rng::with_seed(Default::default()); let bytes = rand.gen::<10>(); assert_ne!(&bytes, &[0u8; 10], "output should not match a zeroed array"); ``` -------------------------------- ### Implement TurboCore::fill_bytes Example in Rust Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/prelude/trait.TurboCore_search=u32+-%3E+bool This example demonstrates how to use the `fill_bytes` method from the `TurboCore` trait to generate random bytes. It initializes an `Rng` with a default seed and then fills a byte array, asserting that the output is not a zeroed array, thus confirming random data generation. ```Rust use turborand::prelude::*; let rand = Rng::with_seed(Default::default()); let mut bytes = [0u8; 10]; rand.fill_bytes(&mut bytes); assert_ne!(&bytes, &[0u8; 10], "output should not match a zeroed array"); ``` -------------------------------- ### Example: Using GlobalRng for Random Actions in Rust Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/prelude/struct.GlobalRng_search= Demonstrates how to obtain a mutable reference to GlobalRng within a Bevy system and use its methods (like `f64()` and `chance()`) for generating random values and making probabilistic decisions. This example requires 'chacha' or 'wyrand' features. ```rust use bevy::prelude::*; use bevy_turborand::prelude::*; use std::iter::repeat_with; fn contrived_random_actions(mut rand: ResMut) { let rand = rand.get_mut(); // Important to shadow the rand mut reference into being an immutable `TurboRand` one. // Now the `TurboRand` instance can be borrowed in multiple places in the iterator without issue. let output: Vec = repeat_with(|| rand.f64()).take(5).filter(|&val| rand.chance(val)).collect(); println!("Received random values: {:?}", output); } ``` -------------------------------- ### ChaChaRng Default Initialization Example Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/prelude/struct.ChaChaRng_search=std%3A%3Avec Demonstrates how to create a ChaChaRng using the `default` method, which is available when the 'std' crate feature is enabled. It highlights that the default instance is seeded randomly and thus not deterministic. ```rust use turborand::prelude::*; let rng1 = ChaChaRng::default(); let rng2 = ChaChaRng::default(); assert_ne!(rng1.u64(..), rng2.u64(..)); ``` -------------------------------- ### Get Type ID for Any Trait Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/prelude/struct.RngComponent_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides a method to get the TypeId of an object implementing the 'Any' trait. This is a fundamental part of Rust's dynamic typing system. ```rust impl Any for T { fn type_id(&self) -> TypeId { // ... implementation details ... } } ``` -------------------------------- ### Bevy Plugin Ready Method Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/prelude/struct.RngPlugin_search= The `ready` method from the Bevy `Plugin` trait checks if the RngPlugin has finished its setup. This is particularly useful for plugins with asynchronous initialization steps, allowing the Bevy app to wait until the plugin is fully ready before proceeding. ```rust fn ready(&self, _app: &App) -> bool ``` -------------------------------- ### bevy_turborand Prelude Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/prelude/index The prelude for `bevy_turborand` exposes all necessary traits for default usage of the crate, as well as components and resources configured by enabled features. ```APIDOC ## Module prelude bevy_turborand ### Description Prelude for `bevy_turborand`, exposing all necessary traits for default usage of the crate, as well as whatever component/resources are configured to be exposed by whichever features are enabled. ### Usage ```rust use bevy_turborand::prelude::*; ``` ``` -------------------------------- ### Get Value by Path Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/prelude/struct.GlobalChaChaRng_search= Provides methods to get a reference or mutable reference to a value within a structure using a reflective path. This allows for dynamic access to nested data. ```rust fn reflect_path<'p>( &self, path: impl ReflectPath<'p>, ) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>> ``` ```rust fn reflect_path_mut<'p>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>> ``` ```rust fn path<'p, T>( &self, path: impl ReflectPath<'p>, ) -> Result<&T, ReflectPathError<'p>> where T: Reflect, ``` ```rust fn path_mut<'p, T>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut T, ReflectPathError<'p>> where T: Reflect, ``` -------------------------------- ### Initialize RandCompat with Default Random Seed (Rust) Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/rng/struct.RandCompat Shows how to initialize RandCompat using the default() method, which creates an instance with a randomly generated seed. Note that this is not deterministic. This requires the 'std' feature. ```rust use turborand::prelude::*; use rand_core::RngCore; let mut rng1 = RandCompat::::default(); let mut rng2 = RandCompat::::default(); assert_ne!(rng1.next_u64(), rng2.next_u64()); ``` -------------------------------- ### Get Value by Path (Reflect) Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/prelude/struct.RngComponent_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides methods to get immutable or mutable references to a value within a structure using a `ReflectPath`. This is a core part of Bevy's reflection capabilities for accessing nested data. ```rust impl GetPath for T where T: Reflect + ?Sized { fn reflect_path<'p>( &self, path: impl ReflectPath<'p>, ) -> Result<&'static (dyn PartialReflect + 'static), ReflectPathError<'p>> { // ... implementation details ... } fn reflect_path_mut<'p>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&'static mut (dyn PartialReflect + 'static), ReflectPathError<'p>> { // ... implementation details ... } } ``` -------------------------------- ### From Trait Implementation Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/rng/struct.RandCompat_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Documentation for the From trait implementation. ```APIDOC ## impl From for T ### Description Provides a trivial conversion from a type to itself. ### Method `from(t: T) -> T` ### Description Returns the argument unchanged. ``` -------------------------------- ### Blanket Implementations Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/rng/struct.ChaChaRng Documentation for blanket implementations, including Any, Borrow, BorrowMut, CloneToUninit, Downcast, DowncastSend, DynEq, Equivalent, From, FromWorld, Into, IntoEither, IntoResult, Is, Serialize, ToOwned, and TryFrom. ```APIDOC ## Blanket Implementations ### impl Any for T where T: 'static + ?Sized #### fn type_id(&self) -> TypeId ### Description Gets the `TypeId` of `self`. Read more ### impl Borrow for T where T: ?Sized #### fn borrow(&self) -> &T ### Description Immutably borrows from an owned value. Read more ### impl BorrowMut for T where T: ?Sized #### fn borrow_mut(&mut self) -> &mut T ### Description Mutably borrows from an owned value. Read more ### impl CloneToUninit for T where T: Clone #### unsafe fn clone_to_uninit(&self, dest: *mut u8) ### Description 🔬This is a nightly-only experimental API. (`clone_to_uninit`) Performs copy-assignment from `self` to `dest`. Read more ### impl Downcast for T where T: Any #### fn into_any(self: Box) -> Box ### Description Converts `Box` (where `Trait: Downcast`) to `Box`, which can then be `downcast` into `Box` where `ConcreteType` implements `Trait`. #### fn into_any_rc(self: Rc) -> Rc ### Description Converts `Rc` (where `Trait: Downcast`) to `Rc`, which can then be further `downcast` into `Rc` where `ConcreteType` implements `Trait`. #### fn as_any(&self) -> &(dyn Any + 'static) ### Description Converts `&Trait` (where `Trait: Downcast`) to `&Any`. This is needed since Rust cannot generate `&Any`’s vtable from `&Trait`’s. #### fn as_any_mut(&mut self) -> &mut (dyn Any + 'static) ### Description Converts `&mut Trait` (where `Trait: Downcast`) to `&Any`. This is needed since Rust cannot generate `&mut Any`’s vtable from `&mut Trait`’s. ### impl DowncastSend for T where T: Any + Send #### fn into_any_send(self: Box) -> Box ### Description Converts `Box` (where `Trait: DowncastSend`) to `Box`, which can then be `downcast` into `Box` where `ConcreteType` implements `Trait`. ### impl DynEq for T where T: Any + Eq #### fn dyn_eq(&self, other: &(dyn DynEq + 'static)) -> bool ### Description This method tests for `self` and `other` values to be equal. Read more ### impl Equivalent for Q where Q: Eq + ?Sized, K: Borrow + ?Sized #### fn equivalent(&self, key: &K) -> bool ### Description Compare self to `key` and return `true` if they are equal. ### impl Equivalent for Q where Q: Eq + ?Sized, K: Borrow + ?Sized #### fn equivalent(&self, key: &K) -> bool ### Description Checks if this value is equivalent to the given key. Read more ### impl From for T #### fn from(t: T) -> T ### Description Returns the argument unchanged. ### impl FromWorld for T where T: Default #### fn from_world(_world: &mut World) -> T ### Description Creates `Self` using `default()`. ### impl Into for T where U: From #### fn into(self) -> U ### Description Calls `U::from(self)`. That is, this conversion is whatever the implementation of `From for U` chooses to do. ### impl IntoEither for T #### fn into_either(self, into_left: bool) -> Either ### Description Converts `self` into a `Left` variant of `Either` if `into_left` is `true`. Converts `self` into a `Right` variant of `Either` otherwise. Read more #### fn into_either_with(self, into_left: F) -> Either where F: FnOnce(&Self) -> bool, ### Description Converts `self` into a `Left` variant of `Either` if `into_left(&self)` returns `true`. Converts `self` into a `Right` variant of `Either` otherwise. Read more ### impl IntoResult for T #### fn into_result(self) -> Result ### Description Converts this type into the system output type. ### impl Is for A #### fn is() -> bool where T: Any, ### Description Checks if the current type “is” another type, using a `TypeId` equality comparison. This is most useful in the context of generic logic. Read more ### impl Serialize for T where T: Serialize + ?Sized, #### fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error> ### Description N/A #### fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl> ### Description N/A ### impl ToOwned for T where T: Clone, #### type Owned = T ### Description The resulting type after obtaining ownership. #### fn to_owned(&self) -> T ### Description Creates owned data from borrowed data, usually by cloning. Read more #### fn clone_into(&self, target: &mut T) ### Description Uses borrowed data to replace owned data, usually by cloning. Read more ### impl TryFrom for T where U: Into, #### type Error = Infallible ### Description The type returned in the event of a conversion error. ``` -------------------------------- ### TryFrom Trait Implementation Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/rng/struct.RandCompat_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Documentation for the TryFrom trait implementation. ```APIDOC ## impl TryFrom for T where U: Into ### Description Provides a fallible conversion from type `U` into type `T`. ### Associated Type `Error = Infallible` ### Description The type returned in the event of a conversion error. ### Method `try_from(value: U) -> Result>::Error>` ### Description Performs the conversion. ``` -------------------------------- ### Into Trait Implementation Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/rng/struct.RandCompat_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Documentation for the Into trait implementation. ```APIDOC ## impl Into for T where U: From ### Description Provides a conversion from type `T` into type `U` if `U` implements `From`. ### Method `into(self) -> U` ### Description Calls `U::from(self)`. That is, this conversion is whatever the implementation of `From for U` chooses to do. ``` -------------------------------- ### Determinism Setup Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/index Enabling determinism in your Bevy application by seeding random number generators. ```APIDOC ## Determinism Setup To achieve determinism, seed the `TurboRand` sources. `GlobalRng` and `RngPlugin` can be seeded to set their internal PRNG for deterministic behavior. When `GlobalRng` is seeded, `RngComponent`s can be created by cloning its internal RNG, ensuring a random yet deterministic seed for each component. This allows for varied random states across `RngComponent`s while maintaining an overall deterministic application. `RngComponent`s derived from a seeded `GlobalRng` can also deterministically seed other `RngComponent`s. ### System Ordering for Determinism For determinism to occur, systems must be ordered correctly. Related systems that access the same `RngComponent`s need to be ordered relative to each other. Unrelated systems can run in parallel without affecting the deterministic outcome. For example, systems selecting a `Player` entity with an `RngComponent` must be ordered amongst themselves. Systems selecting an `Item` entity with an `RngComponent` that does not interact with `Player` systems only need to be ordered amongst themselves. ``` -------------------------------- ### Get Type Identifier Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/struct.RngComponent_search=std%3A%3Avec Returns an optional string identifier for the type. This can be `None` if the type does not have a distinct identifier. ```rust fn reflect_type_ident(&self) -> Option<&str>; ``` -------------------------------- ### Equivalence and From/Into Conversions Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/rng/struct.Rng_search=std%3A%3Avec Documentation for checking equivalence between types and for standard `From`/`Into` conversions. ```APIDOC ## impl Equivalent for Q ### Description Provides methods for checking if a value is equivalent to a key. ### Methods #### fn equivalent(&self, key: &K) -> bool Compare self to `key` and return `true` if they are equal. #### fn equivalent(&self, key: &K) -> bool Checks if this value is equivalent to the given key. ## impl From for T ### Description Provides a trivial conversion from a type to itself. ### Methods #### fn from(t: T) -> T Returns the argument unchanged. ## impl Into for T ### Description Provides a conversion from type `T` to type `U` if `U` implements `From`. ### Methods #### fn into(self) -> U Calls `U::from(self)`. ``` -------------------------------- ### Rust: Get &dyn Any from &T Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/rng/struct.Rng_search=u32+-%3E+bool This method converts a reference `&Trait` to `&Any`, which is necessary when Rust cannot automatically generate the vtable for `&Any` from `&Trait`. ```rust impl Downcast for T where T: Any, { fn as_any(&self) -> &(dyn Any + 'static) } ``` -------------------------------- ### Example: Using GlobalChaChaRng in Bevy System (Rust) Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/prelude/struct.GlobalChaChaRng Demonstrates how to use GlobalChaChaRng within a Bevy system to generate random values and perform actions based on randomness. It shows how to obtain a mutable reference to the RNG resource and use its methods like `f64()` and `chance()`. ```rust use bevy::prelude::*; use bevy_turborand::prelude::*; use std::iter::repeat_with; fn contrived_random_actions(mut rand: ResMut) { let rand = rand.get_mut(); // Important to shadow the rand mut reference into being an immutable `TurboRand` one. // Now the `TurboRand` instance can be borrowed in multiple places in the iterator without issue. let output: Vec = repeat_with(|| rand.f64()).take(5).filter(|&val| rand.chance(val)).collect(); println!("Received random values: {:?}", output); } ``` -------------------------------- ### Reflection and Path Operations Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/struct.GlobalChaChaRng_search= Documentation for functions related to reflection and path-based access to data within the crate. ```APIDOC ## Reflection and Path Operations ### Description This section covers functions related to reflection, allowing introspection and manipulation of data structures. It includes methods for getting type paths, dynamic types, and accessing data via paths. ### Method - `reflect_type_path(&self) -> &str` - `reflect_short_type_path(&self) -> &str` - `reflect_type_ident(&self) -> Option<&str>` - `reflect_crate_name(&self) -> Option<&str>` - `reflect_module_path(&self) -> Option<&str>` - `reflect_type_info(&self) -> &'static TypeInfo` - `reflect_path<'p>( &self, path: impl ReflectPath<'p>, ) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>>` - `reflect_path_mut<'p>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>>` - `path<'p, T>( &self, path: impl ReflectPath<'p>, ) -> Result<&T, ReflectPathError<'p>>` (where `T: Reflect`) - `path_mut<'p, T>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut T, ReflectPathError<'p>>` (where `T: Reflect`) ### Endpoint N/A (Methods within traits) ### Parameters - `path`: An object implementing the `ReflectPath` trait, specifying the path to the desired data. - `T`: The expected type of the data being accessed. ### Request Example N/A ### Response - `&str`: String representation of type path information. - `Option<&str>`: Optional string representation of type identifier, crate name, or module path. - `&'static TypeInfo`: Static type information. - `Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>>`: A reference to the reflected data or an error. - `Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>>`: A mutable reference to the reflected data or an error. - `Result<&T, ReflectPathError<'p>>`: A statically typed reference to the data or an error. - `Result<&mut T, ReflectPathError<'p>>`: A statically typed mutable reference to the data or an error. ``` -------------------------------- ### Type ID Retrieval (Rust) Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/prelude/struct.GlobalRng_search= Provides a method to get the `TypeId` of a type. This is a fundamental operation for runtime type introspection. ```rust impl Any for T where T: 'static + ?Sized, #### fn type_id(&self) -> TypeId Gets the `TypeId` of `self`. Read more ``` -------------------------------- ### TryInto Trait Implementation Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/rng/struct.RandCompat_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Documentation for the TryInto trait implementation. ```APIDOC ## impl TryInto for T where U: TryFrom ### Description Provides a fallible conversion from type `T` into type `U`. ### Associated Type `Error = >::Error` ### Description The type returned in the event of a conversion error. ### Method `try_into(self) -> Result>::Error>` ### Description Performs the conversion. ``` -------------------------------- ### Rust: Get TypeId for Any Type Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/prelude/struct.Rng_search=u32+-%3E+bool Retrieves the `TypeId` of a given type. This is fundamental for runtime type identification and is part of the `Any` trait. ```rust impl Any for T where T: 'static + ?Sized, { fn type_id(&self) -> TypeId } ``` -------------------------------- ### Blanket Implementations Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/struct.ChaChaRngComponent_search=std%3A%3Avec Documentation for various blanket implementations provided for generic types, including Any, Borrow, BorrowMut, Bundle, and more. ```APIDOC ## Blanket Implementations ### impl Any for T #### Description Provides `TypeId` information for any type `T` that is `'static` and `?Sized`. #### Methods ##### fn type_id(&self) -> TypeId Gets the `TypeId` of `self`. ### impl Borrow for T #### Description Allows immutable borrowing of a type `T` by itself. #### Methods ##### fn borrow(&self) -> &T Immutably borrows from an owned value. ### impl BorrowMut for T #### Description Allows mutable borrowing of a type `T` by itself. #### Methods ##### fn borrow_mut(&mut self) -> &mut T Mutably borrows from an owned value. ### impl Bundle for C #### Description Enables `C` to be used as a `Bundle` if it implements `Component`. #### Methods ##### fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator + use ##### fn get_component_ids( components: &Components, ) -> impl Iterator> Return a iterator over this `Bundle`’s component ids. This will be `None` if the component has not been registered. ### impl BundleFromComponents for C #### Description Allows creating a `Bundle` from components if `C` implements `Component`. #### Methods ##### unsafe fn from_components(ctx: &mut T, func: &mut F) -> C where F: for<'a> FnMut(&'a mut T) -> OwningPtr<'a>, ### impl CloneToUninit for T #### Description Provides functionality to clone a type `T` to an uninitialized memory location if `T` implements `Clone`. #### Methods ##### unsafe fn clone_to_uninit(&self, dest: *mut u8) Performs copy-assignment from `self` to `dest`. ### impl Downcast for T #### Description Enables downcasting of trait objects to concrete types. #### Methods ##### fn into_any(self: Box) -> Box Converts `Box` to `Box`. ##### fn into_any_rc(self: Rc) -> Rc Converts `Rc` to `Rc`. ##### fn as_any(&self) -> &(dyn Any + 'static) Converts `&Trait` to `&Any`. ##### fn as_any_mut(&mut self) -> &mut (dyn Any + 'static) Converts `&mut Trait` to `&mut Any`. ### impl DowncastSend for T #### Description Enables downcasting of `Send` trait objects to concrete types. #### Methods ##### fn into_any_send(self: Box) -> Box Converts `Box` to `Box`. ### impl DynamicBundle for C #### Description Allows `C` to be used as a dynamic `Bundle` if it implements `Component`. #### Associated Types ##### type Effect = () An operation on the entity that happens _after_ inserting this bundle. #### Methods ##### unsafe fn get_components( ptr: MovingPtr<'_, C>, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> ::Effect Moves the components out of the bundle. ##### unsafe fn apply_effect( _ptr: MovingPtr<'_, MaybeUninit>, _entity: &mut EntityWorldMut<'_>, ) Applies the after-effects of spawning this bundle. ### impl DynamicTypePath for T #### Description Provides dynamic access to type path information if `T` implements `TypePath`. #### Methods ##### fn reflect_type_path(&self) -> &str See `TypePath::type_path`. ##### fn reflect_short_type_path(&self) -> &str See `TypePath::short_type_path`. ##### fn reflect_type_ident(&self) -> Option<&str> See `TypePath::type_ident`. ##### fn reflect_crate_name(&self) -> Option<&str> See `TypePath::crate_name`. ##### fn reflect_module_path(&self) -> Option<&str> See `TypePath::module_path`. ### impl DynamicTyped for T #### Description Provides dynamic access to type information if `T` implements `Typed`. #### Methods ##### fn reflect_type_info(&self) -> &'static TypeInfo See `Typed::type_info`. ### impl From for T #### Description Allows creating a type `T` from itself. #### Methods ##### fn from(t: T) -> T Returns the argument unchanged. ### impl FromWorld for T #### Description Allows creating a type `T` from the `World` if `T` implements `Default`. #### Methods ##### fn from_world(_world: &mut World) -> T Creates `Self` using `default()`. ### impl GetPath for T #### Description Enables retrieving values by path if `T` implements `Reflect`. #### Methods ##### fn reflect_path<'p>( &self, path: impl ReflectPath<'p>, ) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>> Returns a reference to the value specified by `path`. ``` -------------------------------- ### Get Reference to dyn Any Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/prelude/struct.GlobalChaChaRng Converts a `&Trait` to `&Any`, necessary for accessing dynamic dispatch when the vtable cannot be generated directly from `&Trait`. ```rust fn as_any(&self) -> &(dyn Any + 'static) ``` -------------------------------- ### Get Type Identifier using DynamicTypePath Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/prelude/struct.ChaChaRngComponent_search= Returns an optional identifier for the type. This method is part of the DynamicTypePath trait. ```rust #### fn reflect_type_ident(&self) -> Option<&str> See `TypePath::type_ident`. Source§ ``` -------------------------------- ### World Initialization and Either Conversions Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/rng/struct.Rng_search=std%3A%3Avec Covers creating types from the Bevy `World` and converting types into `Either` variants. ```APIDOC ## impl FromWorld for T ### Description Provides methods for creating types from the Bevy `World`, typically using the `Default` trait. ### Methods #### fn from_world(_world: &mut World) -> T Creates `Self` using `default()`. ## impl IntoEither for T ### Description Provides methods for converting a value into either the left or right variant of an `Either` enum. ### Methods #### fn into_either(self, into_left: bool) -> Either Converts `self` into a `Left` variant if `into_left` is `true`, otherwise into a `Right` variant. #### fn into_either_with(self, into_left: F) -> Either where F: FnOnce(&Self) -> bool, Converts `self` into a `Left` variant if the closure `into_left` returns `true`, otherwise into a `Right` variant. ``` -------------------------------- ### Get TypeId using Any trait Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/prelude/struct.ChaChaRngComponent_search= Retrieves the unique TypeId for a given instance. This method is part of the Any trait implementation. ```rust #### fn type_id(&self) -> TypeId Gets the `TypeId` of `self`. Read more Source§ ``` -------------------------------- ### Create and Use RandCompat for Random Data Generation (Rust) Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/rng/struct.RandCompat Demonstrates how to create a new RandCompat instance with a randomized seed and use it to fill a byte buffer with random data. This requires the 'std' feature to be enabled. ```rust use turborand::prelude::*; use rand_core::RngCore; let mut rng = RandCompat::::new(); let mut buffer = [0u8; 32]; rng.fill_bytes(&mut buffer); assert_ne!(&buffer, &[0u8; 32]); ``` -------------------------------- ### Generate Random Boolean Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/prelude/trait.TurboRand_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Returns a random boolean value. Example demonstrates usage with a seeded RNG. ```rust use turborand::prelude::*; let rng = Rng::with_seed(Default::default()); assert_eq!(rng.bool(), true); ``` -------------------------------- ### Conversion Traits Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/prelude/struct.ChaChaRngComponent_search= Implementations for common conversion traits like `Into`, `IntoEither`, `IntoResult`, `TryFrom`, and `TryInto`. ```APIDOC ## POST /into ### Description Calls `U::from(self)`. This conversion is determined by the implementation of `From for U`. ### Method POST ### Endpoint /into ### Parameters #### Request Body - **self** (T) - Required - The value to convert. - **U** (From) - Required - The target type for conversion. ### Response #### Success Response (200) - **U** - The converted value. ## POST /into_either ### Description Converts `self` into a `Left` variant of `Either` if `into_left` is `true`. Otherwise, converts `self` into a `Right` variant. ### Method POST ### Endpoint /into_either ### Parameters #### Request Body - **self** (Self) - Required - The value to convert. - **into_left** (bool) - Required - Determines whether to convert to `Left` or `Right`. ### Response #### Success Response (200) - **Either** - The resulting `Either` variant. ## POST /into_either_with ### Description Converts `self` into a `Left` variant of `Either` if `into_left(&self)` returns `true`. Otherwise, converts `self` into a `Right` variant. ### Method POST ### Endpoint /into_either_with ### Parameters #### Request Body - **self** (Self) - Required - The value to convert. - **into_left** (FnOnce(&Self) -> bool) - Required - A closure that determines the `Either` variant. ### Response #### Success Response (200) - **Either** - The resulting `Either` variant. ## POST /into_result ### Description Converts this type into the system output type. ### Method POST ### Endpoint /into_result ### Parameters #### Request Body - **self** (Self) - Required - The value to convert. ### Response #### Success Response (200) - **Result** - The converted result. ## POST /try_from ### Description Performs the conversion from type `U` to type `T`. ### Method POST ### Endpoint /try_from ### Parameters #### Request Body - **value** (U) - Required - The value to convert. ### Response #### Success Response (200) - **Result>::Error>** - The result of the conversion. ## POST /try_into ### Description Performs the conversion from type `T` to type `U`. ### Method POST ### Endpoint /try_into ### Parameters #### Request Body - **self** (T) - Required - The value to convert. ### Response #### Success Response (200) - **Result>::Error>** - The result of the conversion. ``` -------------------------------- ### Get Crate Name Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/struct.RngComponent_search=std%3A%3Avec Returns the name of the crate where the type is defined. This is useful for understanding the origin of a type in a larger project. ```rust fn reflect_crate_name(&self) -> Option<&str>; ``` -------------------------------- ### GlobalChaChaRng PartialEq Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/struct.GlobalChaChaRng_search= Documentation for the `PartialEq` implementation for `GlobalChaChaRng`, allowing comparison of two instances. Available when the 'chacha' or 'wyrand' features are enabled. ```APIDOC ## GlobalChaChaRng PartialEq ### Description Implements the `PartialEq` trait for `GlobalChaChaRng`, enabling the comparison of two random number generator instances for equality. This functionality is available when the `chacha` or `wyrand` features are enabled. ### Methods - **`eq(&self, other: &GlobalChaChaRng) -> bool`**: Tests if two `GlobalChaChaRng` instances are equal. - **`ne(&self, other: &Rhs) -> bool`**: Tests if two `GlobalChaChaRng` instances are not equal. ### Parameters - **`self`**: The first `GlobalChaChaRng` instance. - **`other`**: The second `GlobalChaChaRng` instance to compare against. - **`Rhs`**: The type of the right-hand side operand for the `ne` comparison. ### Request Example ```rust use bevy_turborand::GlobalChaChaRng; let rng1 = GlobalChaChaRng::new(); let rng2 = GlobalChaChaRng::new(); let are_equal = rng1 == rng2; let are_not_equal = rng1 != rng2; ``` ### Response - **Success Response**: A boolean value indicating whether the two `GlobalChaChaRng` instances are equal (`true`) or not (`false`). ### Response Example ```rust // let are_equal: bool = true; // or false // let are_not_equal: bool = false; // or true ``` ``` -------------------------------- ### Implement DynamicTypePath for Generic Type T Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/struct.ChaChaRngComponent_search= Provides reflection capabilities for getting the type path of a type `T`. Requires `T` to implement `TypePath`. ```rust impl DynamicTypePath for T where T: TypePath ``` -------------------------------- ### Equivalent Trait Implementations Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/rng/struct.RandCompat_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Documentation for the Equivalent trait and its implementations. ```APIDOC ## impl Equivalent for Q where Q: Eq + ?Sized, K: Borrow + ?Sized ### Description Enables checking for equivalence between types. ### Method `equivalent(&self, key: &K) -> bool` ### Description Compare self to `key` and return `true` if they are equal. ### Method `equivalent(&self, key: &K) -> bool` ### Description Checks if this value is equivalent to the given key. ``` -------------------------------- ### Bevy Plugin Finish Method Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/prelude/struct.RngPlugin_search= The `finish` method is called after all plugins have reported being ready. It allows the RngPlugin to complete its setup, potentially integrating with other plugins that have finished their asynchronous initialization. ```rust fn finish(&self, _app: &mut App) ``` -------------------------------- ### Get Type Identifier Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/prelude/struct.RngComponent_search=std%3A%3Avec Returns an optional identifier for the type. This is part of the DynamicTypePath trait, useful for uniquely identifying types. ```rust fn reflect_type_ident(&self) -> Option<&str>; // where T: TypePath ``` -------------------------------- ### Get Type ID for Any Type Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/prelude/struct.RngComponent_search=std%3A%3Avec Retrieves the TypeId of an object. This is part of the Any trait implementation, allowing for runtime type identification. ```rust impl Any for T where T: 'static + ?Sized { fn type_id(&self) -> TypeId; } ``` -------------------------------- ### RandCompat API Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/rng/struct.RandCompat Documentation for the RandCompat struct, its methods, and trait implementations. ```APIDOC ## Struct RandCompat `bevy_turborand::rng` ### Description A wrapper struct around `TurboCore` to allow implementing `RngCore` trait in a compatible manner. ### Methods #### `new()` ```rust pub fn new() -> RandCompat ``` Available on **crate feature`std`** only. Creates a new `RandCompat` with a randomised seed. ##### Example ```rust use turborand::prelude::*; use rand_core::RngCore; let mut rng = RandCompat::::new(); let mut buffer = [0u8; 32]; rng.fill_bytes(&mut buffer); assert_ne!(&buffer, &[0u8; 32]); ``` ### Trait Implementations #### `Default` for `RandCompat` Available on **crate feature`std`** only. Initialises a default instance of `RandCompat`. Warning, the default is seeded with a randomly generated state, so this is **not** deterministic. ##### Example ```rust use turborand::prelude::*; use rand_core::RngCore; let mut rng1 = RandCompat::::default(); let mut rng2 = RandCompat::::default(); assert_ne!(rng1.next_u64(), rng2.next_u64()); ``` #### `From>` for `ChaChaRng` Available on **crate feature`chacha`** only. Converts to this type from the input type. #### `From>` for `Rng` Available on **crate feature`wyrand`** only. Converts to this type from the input type. #### `From` for `RandCompat` Converts to this type from the input type. #### `PartialEq` for `RandCompat` Tests for `self` and `other` values to be equal, and is used by `==`. #### `RngCore` for `RandCompat` ##### `next_u32()` Return the next random `u32`. ##### `next_u64()` Return the next random `u64`. ##### `fill_bytes()` Fill `dest` with random data. ##### `try_fill_bytes()` Fill `dest` entirely with random data. #### `Eq` for `RandCompat` #### `StructuralPartialEq` for `RandCompat` ### Auto Trait Implementations - `Freeze` for `RandCompat` - `RefUnwindSafe` for `RandCompat` - `Send` for `RandCompat` - `Sync` for `RandCompat` - `Unpin` for `RandCompat` - `UnwindSafe` for `RandCompat` ### Blanket Implementations - `Any` for `T` - `Borrow` for `T` - `BorrowMut` for `T` - `Downcast` for `T` - `DowncastSend` for `T` ``` -------------------------------- ### Get Component IDs from Bundle Source: https://docs.rs/bevy_turborand/0.13.0/bevy_turborand/prelude/struct.RngComponent_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Returns an iterator over the component IDs present in a Bundle. If a component has not been registered, it will yield `None`. ```rust impl Bundle for C where C: Component { fn get_component_ids(components: &Components) -> impl Iterator> { // ... implementation details ... } } ```