### Rust Search Examples Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiLayoutTypeBoundary.html?search= These are example search queries demonstrating how to find specific Rust types and function signatures. They cover basic types, type conversions, and generic function signatures with transformations. ```rust std::vec ``` ```rust u32 -> bool ``` ```rust Option, (T -> U) -> Option ``` -------------------------------- ### HashMap Keys Iterator Example in Rust Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiColor.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E This example illustrates how to use the `keys` method to get an iterator over all keys in a HashMap. The order of keys is not guaranteed. This is useful for iterating through the keys of a map. ```rust let mut map = HashMap::new(); map.insert("foo", 0); map.insert("bar", 1); map.insert("baz", 2); for key in map.keys() { // foo, bar, baz // Note that the above order is not guaranteed } ``` -------------------------------- ### Example: Spawn 2D UiLayoutRoot (Rust) Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiLayoutRoot.html?search= Demonstrates how to spawn a 2D UiLayoutRoot component using Bevy's ECS commands. This example shows the creation of a new 2D layout and piping its size from a camera, with a placeholder for spawning child UI elements. ```rust commands.spawn(( UiLayoutRoot::new_2d(), UiFetchFromCamera::<0>, // Pipe the size from Camera )).with_children(|ui| { // ... spawn your Ui Here }); ``` -------------------------------- ### UiState Example Usage in Bevy Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiState.html An example demonstrating how to spawn a UI element with UiState, enabling states like UiHover and defining state-specific layouts and colors using Bevy's ECS and the bevy_lunex crate. ```rust ui.spawn(( // Like this you can enable a state UiHover::new().forward_speed(20.0).backward_speed(4.0), // You can define layouts per state UiLayout::new(vec![ (UiBase::id(), UiLayout::window().full()), (UiHover::id(), UiLayout::window().x(Rl(10.0)).full()) ]), // You can define colors per state UiColor::new(vec![ (UiBase::id(), Color::Srgba(RED).with_alpha(0.8)), (UiHover::id(), Color::Srgba(YELLOW).with_alpha(1.2)) ]), // ... Sprite, Text, etc. // Add observers that enable/disable the hover state component )).observe(hover_set::, true>) .observe(hover_set::, false>); ``` -------------------------------- ### HashMap Capacity Method Example in Rust Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiColor.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E This example demonstrates the `capacity` method, which returns the number of elements a HashMap can hold without reallocating. It shows how to check if a HashMap's capacity meets a certain threshold. ```rust let map = HashMap::with_capacity(5); assert!(map.capacity() >= 5); ``` -------------------------------- ### HashMap Length Method Example in Rust Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiColor.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E This example demonstrates the `len` method, which returns the number of elements currently in a HashMap. It shows how to check the size of the map. ```rust let mut map = HashMap::new(); assert_eq!(map.len(), 0); map.insert("foo", 0); assert_eq!(map.len(), 1); ``` -------------------------------- ### Example: Spawning and Configuring UI States in Rust Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiState.html?search=u32+-%3E+bool Demonstrates how to spawn a UI entity with various state components like UiHover, UiLayout, and UiColor. This example shows how to define layouts and colors specific to different UI states (e.g., Base and Hover) and how to observe pointer events to enable/disable states. ```rust ui.spawn(( // Like this you can enable a state UiHover::new().forward_speed(20.0).backward_speed(4.0), // You can define layouts per state UiLayout::new(vec![ (UiBase::id(), UiLayout::window().full()), (UiHover::id(), UiLayout::window().x(Rl(10.0)).full()) ]), // You can define colors per state UiColor::new(vec![ (UiBase::id(), Color::Srgba(RED).with_alpha(0.8)), (UiHover::id(), Color::Srgba(YELLOW).with_alpha(1.2)) ]), // ... Sprite, Text, etc. // Add observers that enable/disable the hover state component )).observe(hover_set::, true>) .observe(hover_set::, false>); ``` -------------------------------- ### HashMap Iterator Example in Rust Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiColor.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E This example shows how to use the `iter` method to get an iterator over key-value pairs in a HashMap. The order of iteration is not guaranteed. This is useful for accessing both keys and values simultaneously. ```rust let mut map = HashMap::new(); map.insert("foo", 0); map.insert("bar", 1); map.insert("baz", 2); for (key, value) in map.iter() { // ("foo", 0), ("bar", 1), ("baz", 2) // Note that the above order is not guaranteed } ``` -------------------------------- ### Example: Spawning Text with UiTextSize in Rust Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiTextSize.html?search=u32+-%3E+bool Demonstrates how to spawn a text element with UiTextSize, UiLayout, Text2d, and TextFont components. This example shows positioning text using window layout, setting its height with UiTextSize, and configuring font properties. ```rust ui.spawn(( // Position the text using the window layout's position and anchor UiLayout::window().pos((Rh(40.0), Rl(50.0))).anchor(Anchor::CenterLeft).pack(), // This controls the height of the text, so 60% of the parent's node height UiTextSize::from(Rh(60.0)), // You can attach text like this Text2d::new("Button"), // Font size now works as "text resolution" TextFont { font: asset_server.load("fonts/Rajdhani.ttf"), font_size: 64.0, ..Default::default() }, )); ``` -------------------------------- ### Example Usage of UiTextSize (Rust) Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiTextSize.html?search=std%3A%3Avec Demonstrates how to spawn a text element with UiTextSize in Bevy. It shows setting up UiLayout for positioning, UiTextSize for height control, Text2d for the text content, and TextFont for font properties. The example highlights how font size acts as 'text resolution' when UiTextSize is applied. ```rust ui.spawn(( // Position the text using the window layout's position and anchor UiLayout::window().pos((Rh(40.0), Rl(50.0))).anchor(Anchor::CenterLeft).pack(), // This controls the height of the text, so 60% of the parent's node height UiTextSize::from(Rh(60.0)), // You can attach text like this Text2d::new("Button"), // Font size now works as "text resolution" TextFont { font: asset_server.load("fonts/Rajdhani.ttf"), font_size: 64.0, ..Default::default() }, )); ``` -------------------------------- ### Get BuildHasher Reference (Rust) Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiColor.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Returns an immutable reference to the map's `BuildHasher`. This allows inspection of the hashing algorithm used by the HashMap. The example demonstrates creating a HashMap with a specific hasher and then retrieving it. ```Rust pub fn hasher(&self) -> &S ``` -------------------------------- ### Settings Implementation Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/prelude/struct.GamepadCursor.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Documentation for the Settings trait implementation. ```APIDOC ## Settings Trait Implementation ### Description Defines settings for a type that is static, sendable, and syncable. ### Method N/A (Trait Implementation) ### Endpoint N/A (Trait Implementation) ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Get HashMap Capacity (Rust) Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiColor.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Returns the number of elements the map can hold without reallocating. This value is a lower bound, meaning the map might be able to hold more elements than reported. The example shows creating a map with a specific capacity and asserting its length and capacity. ```Rust pub fn capacity(&self) -> usize ``` -------------------------------- ### Get HashMap Capacity (Rust) Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiColor.html?search=std%3A%3Avec Returns the number of elements the map can hold without reallocating. This value is a lower bound, meaning the HashMap might be able to hold more elements than reported but is guaranteed to hold at least this many. The example shows creating a map with capacity and asserting its length and capacity. ```rust pub fn capacity(&self) -> usize ##### §Examples ``` use hashbrown::HashMap; let map: HashMap = HashMap::with_capacity(100); assert_eq!(map.len(), 0); assert!(map.capacity() >= 100); ``` ``` -------------------------------- ### Example: Spawn UI Node with UiLayout (Rust) Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiLayout.html?search= Demonstrates how to spawn a UI node with a UiLayout component. It shows the usage of UiLayout::solid() to define a layout and attaches a Sprite component. ```rust // Must be spawned as a child ui.spawn(( // Use 1 of the 3 available layout types UiLayout::solid().size((1920.0, 1080.0)).scaling(Scaling::Fill).pack(), // Attach image to the node Sprite::from_image(asset_server.load("images/ui/background.png")), )); ``` -------------------------------- ### GetField Trait Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiMeshPlane3d.html?search=std%3A%3Avec Provides methods to get or mutably get field values by name from a struct. ```APIDOC ## GET /websites/rs_bevy_lunex/get_field ### Description Retrieves a reference to a field's value by its name, downcasting it to a specified type `T`. Requires the type `S` to implement `Struct` and `T` to implement `Reflect`. ### Method GET ### Endpoint /websites/rs_bevy_lunex/get_field ### Parameters #### Query Parameters - **name** (string) - Required - The name of the field to retrieve. - **type** (string) - Required - The expected type `T` of the field (e.g., "i32", "String"). ### Request Example ``` GET /websites/rs_bevy_lunex/get_field?name=my_field&type=i32 ``` ### Response #### Success Response (200) - **field_value** (T) - An optional reference to the field's value, downcast to type `T`. #### Response Example ```json { "field_value": } ``` ``` ```APIDOC ## PUT /websites/rs_bevy_lunex/get_field_mut ### Description Retrieves a mutable reference to a field's value by its name, downcasting it to a specified type `T`. Requires the type `S` to implement `Struct` and `T` to implement `Reflect`. ### Method PUT ### Endpoint /websites/rs_bevy_lunex/get_field_mut ### Parameters #### Query Parameters - **name** (string) - Required - The name of the field to retrieve. - **type** (string) - Required - The expected type `T` of the field (e.g., "i32", "String"). ### Request Example ``` PUT /websites/rs_bevy_lunex/get_field_mut?name=my_field&type=i32 ``` ### Response #### Success Response (200) - **field_value_mut** (T) - An optional mutable reference to the field's value, downcast to type `T`. #### Response Example ```json { "field_value_mut": } ``` ``` -------------------------------- ### clone_to_uninit Function Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/prelude/struct.Text3dPlugin.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Documentation for the `clone_to_uninit` function, a nightly-only experimental API. ```APIDOC ## clone_to_uninit Function ### Description This is a nightly-only experimental API. Performs copy-assignment from `self` to `dest`. ### Method `unsafe fn clone_to_uninit(&self, dest: *mut u8)` ``` -------------------------------- ### Get Path Reflection Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/prelude/struct.Rl.html?search= Provides methods to get references to values within a structure using a path, both statically typed and dynamically typed. ```APIDOC ## Get Path Reflection ### Description This trait allows for retrieving references (mutable or immutable) to nested values within a structure using a specified path. It supports both statically typed retrieval and dynamic retrieval via `PartialReflect`. ### Methods #### `reflect_path<'p>( &self, path: impl ReflectPath<'p>, ) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>>` Returns a reference to the value specified by `path` as a `dyn PartialReflect`. #### `reflect_path_mut<'p>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>>` Returns a mutable reference to the value specified by `path` as a `dyn PartialReflect`. #### `path<'p, T>( &self, path: impl ReflectPath<'p>, ) -> Result<&T, ReflectPathError<'p>> where T: Reflect` Returns a statically typed reference to the value specified by `path`. #### `path_mut<'p, T>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut T, ReflectPathError<'p>> where T: Reflect` Returns a statically typed mutable reference to the value specified by `path`. ### Parameters - **self**: The instance implementing `GetPath`. - **path**: An object implementing `ReflectPath` specifying the path to the desired value. - **T**: The expected static type of the value (for `path` and `path_mut`). ### Response - **Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>>**: A reference to the dynamically reflected value or an error. - **Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>>**: A mutable reference to the dynamically reflected value or an error. - **Result<&T, ReflectPathError<'p>>**: A statically typed reference to the value or an error. - **Result<&mut T, ReflectPathError<'p>>**: A statically typed mutable reference to the value or an error. ### Examples ```rust let structure: &MyStruct = &...; let path_spec = "field.nested_field"; // Get a dynamically reflected value let reflected_value = structure.reflect_path(path_spec)?; // Get a statically typed value let typed_value: &i32 = structure.path(path_spec)?; ``` ``` -------------------------------- ### Prelude Components' equivalent Method Source: https://docs.rs/bevy_lunex/latest/src/bevy_lunex/lib.rs.html?search=u32+-%3E+bool Documents the 'equivalent' method found in various prelude components like SystemCursorIcon, TextAlign, GlyphMeta, Style, Weight, StrokeJoin, and Text3dSet. All share the same generic type constraint where 'u32' matches 'K'. ```APIDOC ## GET /websites/rs_bevy_lunex/prelude/*::equivalent ### Description This documentation covers the `equivalent` method signature present in multiple prelude components of the Bevy Lunex library, including `SystemCursorIcon`, `TextAlign`, `GlyphMeta`, `Style`, `Weight`, `StrokeJoin`, and `Text3dSet`. Each of these methods compares two instances and returns a boolean. The generic type parameter `K` is universally constrained to `u32`. ### Method N/A (These are method signatures, not REST endpoints) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust // Example usage (conceptual for any of the prelude components) let component1: SomePreludeComponent; let component2: SomePreludeComponent; let are_equivalent = component1.equivalent(&component2); ``` ### Response #### Success Response (200) - **bool** (bool) - Returns `true` if the two instances are considered equivalent, `false` otherwise. #### Response Example ```json false ``` ### Type Constraint - `K` must match `u32` ``` -------------------------------- ### Settings Implementation Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/prelude/struct.GamepadCursor.html?search=std%3A%3Avec Documentation for the Settings implementation for static, Send, and Sync types. ```APIDOC ## Settings for T ### Description Implementation of Settings for types T that are 'static, Send, and Sync. ### Method N/A (Trait implementation) ### Endpoint N/A (Rust implementation detail) ### Parameters None ### Request Example N/A ### Response N/A #### Success Response (N/A) N/A #### Response Example N/A ``` -------------------------------- ### Get Path Value via Reflection (Rust) Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.Vw.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides methods to get a reference or mutable reference to a value within a structure using a reflective path. It also allows getting a statically typed reference or mutable reference. Requires the target type to implement `Reflect` and the path to implement `ReflectPath`. ```rust fn reflect_path<'p>( &self, path: impl ReflectPath<'p>, ) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>> where S: Reflect + ?Sized ``` ```rust fn reflect_path_mut<'p>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>> where S: Reflect + ?Sized ``` ```rust fn path<'p, T>( &self, path: impl ReflectPath<'p>, ) -> Result<&T, ReflectPathError<'p>> where T: Reflect, S: Reflect + ?Sized ``` ```rust fn path_mut<'p, T>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut T, ReflectPathError<'p>> where T: Reflect, S: Reflect + ?Sized ``` -------------------------------- ### UI Systems: Equivalent Methods Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/prelude/struct.Rl.html?search=u32+-%3E+bool A collection of equivalence check methods used by Bevy Lunex UI systems to compare component states. ```APIDOC ## Method: equivalent ### Description Checks if a given key matches the internal state of UI components like Style, TextAlign, or GlyphMeta. ### Endpoint bevy_lunex::prelude::[Component]::equivalent ### Parameters - **other** (&K) - Required - The key to compare against. ### Response - **bool** - Returns true if the component state is equivalent to the provided key. ``` -------------------------------- ### Getting &dyn Any from &T using Downcast in Rust Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/enum.Scaling.html?search= The `Downcast` trait provides `as_any` to get an `&dyn Any` reference from `&T`. This is necessary because Rust cannot directly generate the vtable for `&Any` from `&T`. ```rust impl Downcast for T where T: Any, { fn as_any(&self) -> &(dyn Any + 'static) } ``` -------------------------------- ### Get a value from HashMap by key Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiColor.html?search=std%3A%3Avec The `get` method retrieves an immutable reference to the value associated with a given key. It returns `Some(&V)` if the key exists and `None` otherwise. ```rust use std::collections::HashMap; let mut map = HashMap::new(); map.insert("foo", 0); assert_eq!(map.get("foo"), Some(&0)); assert_eq!(map.get("bar"), None); ``` -------------------------------- ### Get HashMap Size with len() in Rust Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiColor.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Shows how to use the `len()` method of `hashbrown::HashMap` to get the number of elements it contains. This is useful for checking the current size of the map. ```rust use hashbrown::HashMap; let mut a = HashMap::new(); assert_eq!(a.len(), 0); a.insert(1, "a"); assert_eq!(a.len(), 1); ``` -------------------------------- ### Get Struct Field by Name Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiHover.html?search=u32+-%3E+bool Provides methods to get a reference or a mutable reference to a struct field by its name. The field's value is downcasted to a specified `Reflect` type. ```rust fn get_field(&self, name: &str) -> Option<&T> where T: Reflect fn get_field_mut(&mut self, name: &str) -> Option<&mut T> where T: Reflect ``` -------------------------------- ### Initialize and Configure Window Layout Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiLayoutTypeWindow.html Methods for creating a new window layout and modifying its properties using a builder-like pattern. ```rust let window = UiLayoutTypeWindow::new() .pos(Vec2::new(10.0, 10.0)) .size(Vec2::new(100.0, 50.0)) .anchor(Anchor::TopLeft); ``` -------------------------------- ### Get Path Reflection (Rust) Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/enum.UiDepth.html?search= Provides methods to get references to values within a structure using a path. It supports both immutable and mutable references, and statically typed references. ```rust fn reflect_path<'p>( &self, path: impl ReflectPath<'p>, ) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>> Returns a reference to the value specified by `path`. Read more ``` ```rust fn reflect_path_mut<'p>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>> Returns a mutable reference to the value specified by `path`. Read more ``` ```rust fn path<'p, T>( &self, path: impl ReflectPath<'p>, ) -> Result<&T, ReflectPathError<'p>> where T: Reflect, Returns a statically typed reference to the value specified by `path`. Read more ``` ```rust fn path_mut<'p, T>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut T, ReflectPathError<'p>> where T: Reflect, Returns a statically typed mutable reference to the value specified by `path`. Read more ``` -------------------------------- ### Get Struct Field Information (Rust) Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiLayoutTypeWindow.html?search=std%3A%3Avec Allows accessing struct fields by name. It provides methods to get immutable or mutable references to a field, downcasting it to a specific `Reflect` type. ```rust impl GetField for S where S: Struct { fn get_field(&self, name: &str) -> Option<&T> where T: Reflect; fn get_field_mut(&mut self, name: &str) -> Option<&mut T> where T: Reflect; } ``` -------------------------------- ### Configure UiLayoutTypeSolid with builder methods Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiLayoutTypeSolid.html?search= Example of using the fluent builder pattern to configure a solid layout instance. ```rust let layout = UiLayoutTypeSolid::new() .size(Vec2::new(100.0, 100.0)) .align_x(Align::Center) .align_y(Align::Center) .scaling(Scaling::Fill); ``` -------------------------------- ### Get Allocation Size of Rust HashMap Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiColor.html Demonstrates how to get the total allocated memory size of a Rust HashMap in bytes using `allocation_size`. This can be useful for performance analysis and memory management. ```rust use std::collections::HashMap; use std::mem::size_of; let mut map = HashMap::new(); assert_eq!(map.allocation_size(), 0); map.insert("foo", 0u32); assert!(map.allocation_size() >= size_of::<&'static str>() + size_of::()); ``` -------------------------------- ### Initialize Text3d component Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/prelude/struct.Text3d.html Shows basic instantiation of the Text3d component, either as a simple string or from an existing entity. ```rust use bevy_lunex::prelude::*; // Create simple text without parsing let simple_text = Text3d::new("Hello World"); // Create from an existing entity let entity_text = Text3d::from_extract(entity_id); ``` -------------------------------- ### Equivalent Methods Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiLayoutRoot.html?search=u32+-%3E+bool Comparison methods used to check equivalence between UI system components and generic keys. ```APIDOC ## [METHOD] equivalent ### Description Compares a component instance against a generic key K to determine equivalence. ### Parameters - **self** (&) - Required - The component instance. - **other** (&K) - Required - The key to compare against. ### Returns - **bool** - Returns true if the component is equivalent to the provided key. ### Implementations Applies to: `UiSystems`, `SystemCursorIcon`, `TextAlign`, `GlyphMeta`, `Style`, `Weight`, `StrokeJoin`, and `Text3dSet`. ``` -------------------------------- ### Get Field by Name and Type (Rust) Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiEmbedding.html Provides methods to get a reference or mutable reference to a struct field by its name, downcasting it to a specified type `T` that implements `Reflect`. This is useful for dynamic field access in Bevy. ```rust impl GetField for S where S: Struct, { fn get_field(&self, name: &str) -> Option<&T> where T: Reflect, { // Implementation details... } fn get_field_mut(&mut self, name: &str) -> Option<&mut T> where T: Reflect, { // Implementation details... } } ``` -------------------------------- ### Reflection and Type Path Methods Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/prelude/struct.GamepadCursor.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides methods for reflecting crate names and module paths, useful for introspection and debugging. ```APIDOC ## GET /websites/rs_bevy_lunex/reflect_crate_name ### Description Retrieves the crate name associated with the type. ### Method GET ### Endpoint /websites/rs_bevy_lunex/reflect_crate_name ### Parameters None ### Request Example None ### Response #### Success Response (200) - **Option<&str>** - An optional string slice representing the crate name. #### Response Example ```json { "crate_name": "bevy_lunex" } ``` ## GET /websites/rs_bevy_lunex/reflect_module_path ### Description Retrieves the module path associated with the type. ### Method GET ### Endpoint /websites/rs_bevy_lunex/reflect_module_path ### Parameters None ### Request Example None ### Response #### Success Response (200) - **Option<&str>** - An optional string slice representing the module path. #### Response Example ```json { "module_path": "bevy_lunex::some_module" } ``` ``` -------------------------------- ### Rh Struct Arithmetic Examples in Rust Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/prelude/struct.Rh.html?search= Demonstrates how to use the Rh struct with arithmetic operations like addition and multiplication. These examples show how Rh values can be combined or scaled. ```rust let a: Rh = Rh(25.0) + Rh(40.0); // -> 65% let b: Rh = Rh(25.0) * 3.0; // -> 75% ``` -------------------------------- ### Unsafe Get Disjoint Mutable Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiColor.html?search=u32+-%3E+bool Attempts to get mutable references to multiple values simultaneously without validating that the values are unique. This is an unsafe operation and can lead to undefined behavior if keys overlap. ```APIDOC ## GET /get_disjoint_unchecked_mut ### Description Attempts to get mutable references to `N` values in the map at once, without validating that the values are unique. ### Method GET ### Endpoint `/get_disjoint_unchecked_mut` ### Parameters #### Query Parameters - **keys** (array of strings) - Required - An array of keys to look up. ### Request Example ```json { "keys": ["key1", "key2"] } ``` ### Response #### Success Response (200) - **Option<&mut V>** (array) - An array of mutable references to the values. `None` is used for missing keys. #### Response Example ```json [ "&mut value1", "&mut value2" ] ``` ### Safety Calling this method with overlapping keys is undefined behavior even if the resulting references are not used. ``` -------------------------------- ### VZip Implementation Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/prelude/struct.GamepadCursor.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Documentation for the VZip trait implementation, including the `vzip` function. ```APIDOC ## VZip Trait Implementation ### Description Provides functionality for zipping multiple lanes of data. ### Method N/A (Trait Implementation) ### Endpoint N/A (Trait Implementation) ### Parameters N/A ### Request Example N/A ### Response N/A ## fn vzip(self) -> V ### Description Zips the lanes of the current object. ### Method N/A (Function within Trait) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Settings Implementation Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiColor.html?search=u32+-%3E+bool Documentation for the `Settings` trait implementation. ```APIDOC ## impl Settings for T ### Description Trait implementation for types that are `'static + Send + Sync`. ``` -------------------------------- ### Get Many Key-Value Mutable References (Deprecated) Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiColor.html This method is deprecated and should be replaced with `get_disjoint_key_value_mut`. It attempts to get mutable references to multiple values and their corresponding keys without ensuring value uniqueness. ```rust pub fn get_many_key_value_mut( &mut self, ks: [&Q; N], ) -> [Option<(&K, &mut V)>; N] where Q: Hash + Equivalent + ?Sized, ``` -------------------------------- ### Implement IntoScheduleConfigs for System Set Configuration in Rust Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/enum.UiSystems.html?search= This implementation provides extensive methods for configuring how systems are run within a schedule. It allows setting dependencies (`before`, `after`), conditions (`run_if`), grouping into sets, and managing potential ambiguities. ```rust impl IntoScheduleConfigs, ()> for S where S: SystemSet, { fn into_configs(self) -> ScheduleConfigs>; fn in_set(self, set: impl SystemSet) -> ScheduleConfigs; fn before(self, set: impl IntoSystemSet) -> ScheduleConfigs; fn after(self, set: impl IntoSystemSet) -> ScheduleConfigs; fn before_ignore_deferred(self, set: impl IntoSystemSet) -> ScheduleConfigs; fn after_ignore_deferred(self, set: impl IntoSystemSet) -> ScheduleConfigs; fn distributive_run_if(self, condition: impl SystemCondition + Clone) -> ScheduleConfigs; fn run_if(self, condition: impl SystemCondition) -> ScheduleConfigs; fn ambiguous_with(self, set: impl IntoSystemSet) -> ScheduleConfigs; fn ambiguous_with_all(self) -> ScheduleConfigs; fn chain(self) -> ScheduleConfigs; fn chain_ignore_deferred(self) -> ScheduleConfigs; } ``` -------------------------------- ### Unsafe Get Disjoint Mutable Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiColor.html Attempts to get mutable references to multiple values simultaneously without validating uniqueness. Use with extreme caution as overlapping keys lead to undefined behavior. ```APIDOC ## GET /hashmap/get_disjoint_unchecked_mut ### Description Attempts to get mutable references to `N` values in the map at once, without validating that the values are unique. This is an unsafe operation. ### Method GET ### Endpoint `/hashmap/get_disjoint_unchecked_mut` #### Query Parameters - **keys** (array of strings) - Required - An array of keys to look up. ### Safety Calling this method with overlapping keys is undefined behavior, even if the resulting references are not used. For a safe alternative, use `get_disjoint_mut`. ### Response #### Success Response (200) - **[Option<&mut V>; N]** - An array of mutable references to the values, or None if a key is not found. #### Response Example ```json { "results": [ "&mut ", "&mut " ] } ``` ``` -------------------------------- ### UiLayoutType Reflection: Getting Type Information Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/enum.UiLayoutType.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Methods for retrieving type information and properties of a UiLayoutType instance through reflection. This includes getting the represented type info, its kind, and immutable/mutable references. ```rust fn get_represented_type_info(&self) -> Option<&'static TypeInfo> Returns the `TypeInfo` of the type _represented_ by this value. Read more Source§ ``` ```rust fn reflect_kind(&self) -> ReflectKind Returns a zero-sized enumeration of “kinds” of type. Read more Source§ ``` ```rust fn reflect_ref(&self) -> ReflectRef<'_> Returns an immutable enumeration of “kinds” of type. Read more Source§ ``` ```rust fn reflect_mut(&mut self) -> ReflectMut<'_> Returns a mutable enumeration of “kinds” of type. Read more Source§ ``` -------------------------------- ### Initialize Text3d Components Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/prelude/struct.Text3d.html?search=u32+-%3E+bool Utility methods to create a new Text3d component from a simple string or an existing entity. ```rust pub fn new(s: impl ToString) -> Text3d; pub fn from_extract(entity: Entity) -> Text3d; ``` -------------------------------- ### Create TextFetch instances in Rust Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/prelude/struct.TextFetch.html Demonstrates how to instantiate a TextFetch component using the provided factory methods. These methods allow for fetching data from a component or an EntityRef. ```rust use bevy_lunex::prelude::TextFetch; use bevy::prelude::*; // Create a fetcher from a component let fetcher_from_comp = TextFetch::fetch_component::( entity, |comp| comp.value.clone() ); // Create a fetcher from an EntityRef let fetcher_from_ref = TextFetch::fetch_entity_ref( entity, |entity_ref| entity_ref.get::().map(|n| n.to_string()) ); ``` -------------------------------- ### HashMap IsEmpty Method Example in Rust Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiColor.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E This example demonstrates the `is_empty` method, which returns `true` if the HashMap contains no elements and `false` otherwise. It's a quick way to check if a map is empty. ```rust let mut map = HashMap::new(); assert!(map.is_empty()); map.insert("foo", 0); assert!(!map.is_empty()); ``` -------------------------------- ### POST /bundle/spawn Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiState.html?search=u32+-%3E+bool Handles the dynamic spawning of component bundles with associated effects. ```APIDOC ## POST /bundle/spawn ### Description Applies a dynamic bundle to an entity and executes the associated post-insertion effects. ### Method POST ### Endpoint /bundle/spawn ### Request Body - **bundle_data** (object) - Required - The component bundle to be applied. ### Response #### Success Response (200) - **status** (string) - Confirmation of bundle application and effect execution. #### Response Example { "status": "success" } ``` -------------------------------- ### HashMap Mutable Iterator Example in Rust Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiColor.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E This example demonstrates the `iter_mut` method, which provides an iterator for mutable access to key-value pairs in a HashMap. The order of iteration is not guaranteed. This is useful for modifying both keys and values. ```rust let mut map = HashMap::new(); map.insert("foo", 0); map.insert("bar", 1); map.insert("baz", 2); for (key, value) in map.iter_mut() { // ("foo", 0), ("bar", 1), ("baz", 2) // Note that the above order is not guaranteed } ``` -------------------------------- ### Implement Conversion and Equality for UiLayoutRoot Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiLayoutRoot.html Demonstrates the implementation of IntoReturn for conversion and PartialEq for equality testing on the UiLayoutRoot struct. ```rust impl IntoReturn for UiLayoutRoot { fn into_return<'into_return>(self) -> Return<'into_return> where Self: 'into_return { // Implementation logic } } impl PartialEq for UiLayoutRoot { fn eq(&self, other: &UiLayoutRoot) -> bool { // Equality logic } } ``` -------------------------------- ### HashMap Mutable Values Iterator Example in Rust Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiColor.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E This example demonstrates the `values_mut` method, which provides an iterator for mutable access to all values in a HashMap. The order of values is not guaranteed. This is useful for modifying values in place. ```rust let mut map = HashMap::new(); map.insert("foo", 0); map.insert("bar", 1); map.insert("baz", 2); for key in map.values_mut() { // 0, 1, 2 // Note that the above order is not guaranteed } ``` -------------------------------- ### Settings Implementation Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.UiColor.html Documentation for types implementing the `Settings` trait, typically used for configuration. ```APIDOC ## Settings Implementation ### Description Indicates that a type implements the `Settings` trait, commonly used for managing application settings. ### Method `impl Settings for T where T: 'static + Send + Sync` ### Parameters - **T** (Type) - The type that must be `'static`, `Send`, and `Sync`. ``` -------------------------------- ### Reflectable and Settings Traits Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/prelude/struct.Rl.html Documentation for traits related to reflection capabilities and configuration settings. ```APIDOC ## Reflectable for T ### Description Trait for types that can be reflected upon. ### Method No methods, it's a marker trait that requires `Reflect`, `GetTypeRegistration`, `Typed`, and `TypePath`. ### Parameters None ### Request Example ```rust // This is a marker trait, usage is implicit. // fn inspect(value: &T) { /* ... */ } ``` ### Response #### Success Response (200) Indicates the type supports reflection. #### Response Example ```json { "example": "Type is Reflectable" } ``` ## Settings for T ### Description Trait for types that hold configuration settings. ### Method No methods, it's a marker trait that requires `'static + Send + Sync`. ### Parameters None ### Request Example ```rust // This is a marker trait, usage is implicit. // fn apply_settings(settings: T) { /* ... */ } ``` ### Response #### Success Response (200) Indicates the type holds settings and is thread-safe. #### Response Example ```json { "example": "Type holds settings and is thread-safe" } ``` ``` -------------------------------- ### Reverse Curve on X-axis Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/prelude/struct.Vh.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Create a new `Curve` by inverting this curve on the x-axis. This effectively plays the curve backwards, starting at its end domain and transitioning to its start domain, while maintaining the original domain. ```rust fn reverse(self) -> Result, ReverseError> ``` -------------------------------- ### Get and Mutate UI Layout Solid References (Rust) Source: https://docs.rs/bevy_lunex/latest/src/bevy_lunex/lib.rs.html?search=std%3A%3Avec Provides functions to get immutable and mutable references to `UiLayoutTypeSolid` from a `UiLayout` based on a `TypeId`. It uses pattern matching to extract the solid if present, returning `None` otherwise. ```rust pub fn get_solid(&self, id: TypeId) -> Option<&UiLayoutTypeSolid> { let UiLayoutType::Solid(solid) = self.layouts.get(&id)? else { return None; }; Some(solid) } pub fn get_mut_solid(&mut self, id: TypeId) -> Option<&mut UiLayoutTypeSolid> { let UiLayoutType::Solid(solid) = self.layouts.get_mut(&id)? else { return None; }; Some(solid) } ``` -------------------------------- ### WithSubscriber Implementation Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/prelude/struct.GamepadCursor.html?search=std%3A%3Avec Documentation for the WithSubscriber implementation, allowing attachment of subscribers. ```APIDOC ## WithSubscriber for T ### Description Implementation of WithSubscriber for types T. ### Methods #### `with_subscriber(self, subscriber: S) -> WithDispatch` Attaches the provided `Subscriber` to this type, returning a `WithDispatch` wrapper. #### `with_current_subscriber(self) -> WithDispatch` Attaches the current default `Subscriber` to this type, returning a `WithDispatch` wrapper. ### Endpoint N/A (Rust implementation detail) ### Parameters - `subscriber` (S): The subscriber to attach (must implement `Into`) ### Request Example N/A ### Response Returns a `WithDispatch` wrapper. #### Success Response (N/A) N/A #### Response Example N/A ``` -------------------------------- ### Get and Mutate UI Layout Window References (Rust) Source: https://docs.rs/bevy_lunex/latest/src/bevy_lunex/lib.rs.html?search=std%3A%3Avec Provides functions to get immutable and mutable references to `UiLayoutTypeWindow` from a `UiLayout` based on a `TypeId`. It uses pattern matching to extract the window if present, returning `None` otherwise. ```rust pub fn get_window(&self, id: TypeId) -> Option<&UiLayoutTypeWindow> { let UiLayoutType::Window(window) = self.layouts.get(&id)? else { return None; }; Some(window) } pub fn get_mut_window(&mut self, id: TypeId) -> Option<&mut UiLayoutTypeWindow> { let UiLayoutType::Window(window) = self.layouts.get_mut(&id)? else { return None; }; Some(window) } ``` -------------------------------- ### Reflection Methods Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/enum.GamepadCursorMode.html?search=u32+-%3E+bool This section details various methods available for reflection, including applying values, checking type kinds, and obtaining different views of the reflected data. ```APIDOC ## Reflection API This API provides a set of methods for runtime reflection, enabling introspection and manipulation of data structures. ### `try_apply` #### Description Tries to `apply` a reflected value to this value. #### Method `fn try_apply(&mut self, __value_param: &dyn PartialReflect) -> Result<(), ApplyError>` ### `reflect_kind` #### Description Returns a zero-sized enumeration of "kinds" of type. #### Method `fn reflect_kind(&self) -> ReflectKind` ### `reflect_ref` #### Description Returns an immutable enumeration of "kinds" of type. #### Method `fn reflect_ref(&self) -> ReflectRef<'_>` ### `reflect_mut` #### Description Returns a mutable enumeration of "kinds" of type. #### Method `fn reflect_mut(&mut self) -> ReflectMut<'_>` ### `reflect_owned` #### Description Returns an owned enumeration of "kinds" of type. #### Method `fn reflect_owned(self: Box) -> ReflectOwned` ### `try_into_reflect` #### Description Attempts to cast this type to a boxed, fully-reflected value. #### Method `fn try_into_reflect(self: Box) -> Result, Box>` ### `try_as_reflect` #### Description Attempts to cast this type to a fully-reflected value. #### Method `fn try_as_reflect(&self) -> Option<&dyn Reflect>` ### `try_as_reflect_mut` #### Description Attempts to cast this type to a mutable, fully-reflected value. #### Method `fn try_as_reflect_mut(&mut self) -> Option<&mut dyn Reflect>` ### `into_partial_reflect` #### Description Casts this type to a boxed, reflected value. #### Method `fn into_partial_reflect(self: Box) -> Box` ### `as_partial_reflect` #### Description Casts this type to a reflected value. #### Method `fn as_partial_reflect(&self) -> &dyn PartialReflect` ### `as_partial_reflect_mut` #### Description Casts this type to a mutable, reflected value. #### Method `fn as_partial_reflect_mut(&mut self) -> &mut dyn PartialReflect` ### `reflect_hash` #### Description Returns a hash of the value (which includes the type). #### Method `fn reflect_hash(&self) -> Option` ### `reflect_partial_eq` #### Description Returns a "partial equality" comparison result. #### Method `fn reflect_partial_eq(&self, value: &dyn PartialReflect) -> Option` ### `reflect_clone` #### Description Attempts to clone `Self` using reflection. #### Method `fn reflect_clone(&self) -> Result, ReflectCloneError>` ### `apply` #### Description Applies a reflected value to this value. #### Method `fn apply(&mut self, value: &(dyn PartialReflect + 'static))` ### `to_dynamic` #### Description Converts this reflected value into its dynamic representation based on its kind. #### Method `fn to_dynamic(&self) -> Box` ### `reflect_clone_and_take` #### Description For a type implementing `PartialReflect`, combines `reflect_clone` and `take` in a useful fashion, automatically constructing an appropriate `ReflectCloneError` if the downcast fails. #### Method `fn reflect_clone_and_take(&self) -> Result where T: 'static, Self: Sized + TypePath` ### `debug` #### Description Debug formatter for the value. #### Method `fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>` ### `is_dynamic` #### Description Indicates whether or not this type is a _dynamic_ type. #### Method `fn is_dynamic(&self) -> bool` ``` -------------------------------- ### Rust: Getting &mut dyn Any from &mut T Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.Rectangle2D.html?search=u32+-%3E+bool Illustrates how to get a mutable reference to `dyn Any` from `&mut T` using `as_any_mut`, where `T` implements `Downcast`. This is required because Rust cannot generate `&mut Any`'s vtable from `&mut T`'s. ```rust impl Downcast for T where T: Any, { fn as_any_mut(&mut self) -> &mut (dyn Any + 'static) { // Implementation details } } ``` -------------------------------- ### CloneToUninit Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/prelude/struct.Vh.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Nightly-only experimental API for cloning data to uninitialized memory. ```APIDOC ## `impl CloneToUninit for T` - **Description**: Nightly-only experimental API for performing copy-assignment from `self` to uninitialized memory (`dest`). Requires `T: Clone`. - **`clone_to_uninit()`**: Performs copy-assignment from `self` to `dest`. ``` -------------------------------- ### Equivalent Method Source: https://docs.rs/bevy_lunex/latest/bevy_lunex/struct.LunexGizmoGroup3d.html?search=u32+-%3E+bool Documentation for the `equivalent` method found in various Bevy Lunex components, used for comparison. ```APIDOC ## Method: equivalent(&self, other: &K) -> bool ### Description Compares the current instance with another instance for equality. This method is specialized for different types within Bevy Lunex. ### Method `equivalent(other: &K)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "Not applicable for method call" } ``` ### Response #### Success Response (200) - **bool** (boolean) - `true` if the instances are equivalent, `false` otherwise. #### Response Example ```json { "example": "Not applicable for method call" } ``` **Note:** This method signature appears in multiple contexts, including: - `bevy_lunex::UiSystems::equivalent` - `bevy_lunex::prelude::SystemCursorIcon::equivalent` - `bevy_lunex::prelude::TextAlign::equivalent` - `bevy_lunex::prelude::GlyphMeta::equivalent` - `bevy_lunex::prelude::Style::equivalent` - `bevy_lunex::prelude::Weight::equivalent` - `bevy_lunex::prelude::StrokeJoin::equivalent` - `bevy_lunex::prelude::Text3dSet::equivalent` In these contexts, `K` is often constrained to `u32`. ```