### CborAssetPlugin Setup Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/cbor/struct.CborAssetPlugin_search=u32+-%3E+bool This section describes how to set up the CborAssetPlugin to load assets of a specific type 'A' from CBOR files. It includes the constructor for creating a new plugin instance with specified file extensions. ```APIDOC ## CborAssetPlugin ### Description Plugin to load your asset type `A` from “Concise Binary Object Representation” (CBOR) files. ### Struct Definition ```rust pub struct CborAssetPlugin { /* private fields */ } ``` ### Constructor #### `new(extensions: &[&'static str]) -> Self` Create a new plugin that will load assets from files with the given extensions. ### Usage Example (Conceptual) ```rust use bevy::prelude::*; use bevy_common_assets::cbor::CborAssetPlugin; // Assuming MyAsset is a type that derives Deserialize and Asset // #[derive(Deserialize, Asset)] // struct MyAsset { ... } fn main() { App::new() .add_plugins(DefaultPlugins) .add_plugin(CborAssetPlugin::::new(&["cbor"])) .run(); } ``` ### Bevy Plugin Implementation This plugin implements the `bevy::prelude::Plugin` trait, providing methods for building and managing the plugin within a Bevy application. #### `build(&self, app: &mut App)` Configures the `App` to which this plugin is added. #### `ready(&self, _app: &App) -> bool` Checks if the plugin has finished its setup. Useful for asynchronous operations. #### `finish(&self, _app: &mut App)` Finishes adding the plugin to the `App` after all other plugins are ready. #### `cleanup(&self, _app: &mut App)` Runs after all plugins are built and finished, before the app schedule is executed. #### `name(&self) -> &str` Returns the name of the plugin, used for uniqueness checks and debugging. #### `is_unique(&self) -> bool` Indicates if the plugin can be meaningfully instantiated multiple times. Defaults to true. ``` -------------------------------- ### Implement Bevy Plugin Ready Method for CborAssetPlugin Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/cbor/struct.CborAssetPlugin_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Implements the 'ready' method for the CborAssetPlugin. This method is used to check if the plugin has completed its asynchronous setup, which is useful for plugins that depend on external resources or initialization processes. ```rust fn ready(&self, _app: &App) -> bool ``` -------------------------------- ### Example: Using CsvAssetPlugin in Bevy App Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/csv/struct.CsvAssetPlugin_search= This example demonstrates how to add the `CsvAssetPlugin` to a Bevy application. It specifies the asset type `TreePosition` and configures the plugin to load files with the '.csv' extension, using a semicolon (';') as the delimiter. ```rust App::new() .add_plugins(CsvAssetPlugin::::new(&["some_file.csv"]).with_delimiter(b';')); ``` -------------------------------- ### MsgPackAssetPlugin Bevy Plugin Implementation (Rust) Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/msgpack/struct.MsgPackAssetPlugin_search= Implements the Bevy `Plugin` trait for `MsgPackAssetPlugin`. This includes methods for configuring the App (`build`), checking plugin readiness (`ready`), finishing setup (`finish`), performing cleanup (`cleanup`), and defining the plugin's name (`name`) and uniqueness (`is_unique`). ```rust impl where for<'de> A: Deserialize<'de> + Asset, { fn build(&self, app: &mut App) fn ready(&self, _app: &App) -> bool fn finish(&self, _app: &mut App) fn cleanup(&self, _app: &mut App) fn name(&self) -> &str fn is_unique(&self) -> bool } ``` -------------------------------- ### Implement Bevy Plugin Finish Method for CborAssetPlugin Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/cbor/struct.CborAssetPlugin_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Implements the 'finish' method for the CborAssetPlugin. This method is called after all plugins have finished their setup, allowing for any finalization steps required by the CBOR asset loading plugin. ```rust fn finish(&self, _app: &mut App) ``` -------------------------------- ### Bevy Plugin Implementation for RonAssetPlugin (Rust) Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/ron/struct.RonAssetPlugin Demonstrates the implementation of the Bevy `Plugin` trait for `RonAssetPlugin`. This includes methods for configuring the Bevy application, checking plugin readiness, finishing setup, cleanup, and defining plugin metadata. ```rust impl Plugin for RonAssetPlugin where for<'de> A: Deserialize<'de> + Asset, { fn build(&self, app: &mut App) fn ready(&self, _app: &App) -> bool fn finish(&self, _app: &mut App) fn cleanup(&self, _app: &mut App) fn name(&self) -> &str fn is_unique(&self) -> bool } ``` -------------------------------- ### Implement Plugin Trait for RonAssetPlugin (Rust) Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/ron/struct.RonAssetPlugin_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates the implementation of the Bevy `Plugin` trait for `RonAssetPlugin`. This includes the `build` method for configuring the app, `ready` and `finish` for asynchronous setup, `cleanup` for post-build tasks, and `name` and `is_unique` for plugin identification and management. ```rust impl Plugin for RonAssetPlugin where for<'de> A: Deserialize<'de> + Asset, { fn build(&self, app: &mut App) { // ... implementation details ... } fn ready(&self, _app: &App) -> bool { // ... implementation details ... true } fn finish(&self, _app: &mut App) { // ... implementation details ... } fn cleanup(&self, _app: &mut App) { // ... implementation details ... } fn name(&self) -> &str { // ... implementation details ... "RonAssetPlugin" } fn is_unique(&self) -> bool { // ... implementation details ... true } } ``` -------------------------------- ### Implement Bevy Plugin for RonAssetPlugin (Rust) Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/ron/struct.RonAssetPlugin_search=u32+-%3E+bool Implements the `Plugin` trait for `RonAssetPlugin`. This includes the `build` method to configure the Bevy application, `ready` and `finish` for asynchronous setup management, `cleanup` for post-build tasks, and `name` and `is_unique` for plugin identification and management. ```rust impl Plugin for RonAssetPlugin where for<'de> A: Deserialize<'de> + Asset, { fn build(&self, app: &mut App) fn ready(&self, _app: &App) -> bool fn finish(&self, _app: &mut App) fn cleanup(&self, _app: &mut App) fn name(&self) -> &str fn is_unique(&self) -> bool } ``` -------------------------------- ### Example: Add CsvAssetPlugin to Bevy App Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/csv/struct.CsvAssetPlugin_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates how to add the CsvAssetPlugin to a Bevy application. This example specifies the asset type as 'TreePosition', registers '.csv' files, and sets a semicolon (';') as the delimiter. ```rust App::new() .add_plugins(CsvAssetPlugin::::new(&["some_file.csv"]) .with_delimiter(b';')); ``` -------------------------------- ### Generic Implementations Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/ron/struct.RonAssetLoader_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Documentation for common generic implementations like From, Into, TryFrom, TryInto, and Identity. ```APIDOC ## Generic Implementations ### `impl From for T` - **Description**: A simple implementation of `From` where a type is converted into itself. - **Method**: `from` - **Signature**: `fn from(t: T) -> T` - **Behavior**: Returns the argument unchanged. ### `impl HasTypeWitness for T` - **Description**: Provides a type witness for generic programming. - **Constant**: `WITNESS` - **Signature**: `const WITNESS: W = W::MAKE` - **Behavior**: A constant of the type witness. ### `impl Identity for T` - **Description**: Represents a type that is its own identity. - **Constant**: `TYPE_EQ` - **Type Alias**: `Type` - **Signature**: `const TYPE_EQ: TypeEq::Type> = TypeEq::NEW` - **Behavior**: Proof that `Self` is the same type as `Self::Type`, provides methods for casting between `Self` and `Self::Type`. - **Type Alias**: `type Type = T` ### `impl Into for T` - **Description**: Generic conversion from type `T` to type `U` if `U` implements `From`. - **Method**: `into` - **Signature**: `fn into(self) -> U` - **Behavior**: Calls `U::from(self)`. ### `impl IntoEither for T` - **Description**: Converts a value into either the `Left` or `Right` variant of an `Either` enum. - **Methods**: `into_either`, `into_either_with` - **Signatures**: - `fn into_either(self, into_left: bool) -> Either` - `fn into_either_with(self, into_left: F) -> Either where F: FnOnce(&Self) -> bool` ### `impl IntoResult for T` - **Description**: Converts a value into a `Result`. - **Method**: `into_result` - **Signature**: `fn into_result(self) -> Result` ### `impl Is for A` - **Description**: Checks if a type is an instance of another type using `TypeId` comparison. - **Method**: `is` - **Signature**: `fn is() -> bool where T: Any` ### `impl TryFrom for T` - **Description**: Generic fallible conversion from type `U` to type `T`. - **Type Alias**: `Error` - **Method**: `try_from` - **Signature**: `fn try_from(value: U) -> Result>::Error>` ### `impl TryInto for T` - **Description**: Generic fallible conversion from type `T` to type `U`. - **Type Alias**: `Error` - **Method**: `try_into` - **Signature**: `fn try_into(self) -> Result>::Error>` ``` -------------------------------- ### AssetLoader Methods Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/msgpack/struct.MsgPackAssetLoader_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides methods for interacting with asset loaders, such as getting supported file extensions, deserializing metadata, and retrieving type information. ```APIDOC ## AssetLoader API ### Description Provides methods for interacting with asset loaders, such as getting supported file extensions, deserializing metadata, and retrieving type information. ### Methods #### `extensions(&self) -> &[&str]` * **Description**: Returns a list of extensions supported by this asset loader, without the preceding dot. * **Method**: GET (conceptual) * **Endpoint**: N/A (Instance method) #### `deserialize_meta(&self, meta: &[u8]) -> Result, DeserializeMetaError>` * **Description**: Deserializes metadata from the input `meta` bytes into the appropriate type (erased as `Box`). * **Method**: POST (conceptual) * **Endpoint**: N/A (Instance method) * **Parameters**: * **Query Parameters**: * `meta` (bytes) - Required - The metadata bytes to deserialize. * **Response**: * **Success Response (200)**: * `Box` - The deserialized asset metadata. * **Error Response (e.g., 400)**: * `DeserializeMetaError` - An error indicating failure during deserialization. #### `default_meta(&self) -> Box` * **Description**: Returns the default meta value for the `AssetLoader` (erased as `Box`). * **Method**: GET (conceptual) * **Endpoint**: N/A (Instance method) #### `type_path(&self) -> &'static str` * **Description**: Returns the type path of the `AssetLoader`. * **Method**: GET (conceptual) * **Endpoint**: N/A (Instance method) #### `type_id(&self) -> TypeId` * **Description**: Returns the `TypeId` of the `AssetLoader`. * **Method**: GET (conceptual) * **Endpoint**: N/A (Instance method) #### `asset_type_name(&self) -> &'static str` * **Description**: Returns the type name of the top-level `Asset` loaded by the `AssetLoader`. * **Method**: GET (conceptual) * **Endpoint**: N/A (Instance method) #### `asset_type_id(&self) -> TypeId` * **Description**: Returns the `TypeId` of the top-level `Asset` loaded by the `AssetLoader`. * **Method**: GET (conceptual) * **Endpoint**: N/A (Instance method) ``` -------------------------------- ### Convert Value to String (Rust) Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/json/enum.JsonLoaderError Converts a value that implements the `Display` trait into a `String`. This is a standard way to get a string representation of a type. ```rust fn to_string(&self) -> String where T: Display + ?Sized ``` -------------------------------- ### Conversion and Identity Traits Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/toml/struct.TomlAssetLoader Documentation for various conversion traits like `From`, `Into`, `TryFrom`, `TryInto`, and `Identity`. ```APIDOC ## Conversion and Identity Traits ### Description This section covers traits related to type conversions and identity proofs, including `From`, `Into`, `TryFrom`, `TryInto`, and `Identity`. ### `impl From for T` * **Description**: A simple implementation of `From` where a type is converted from itself. * **Method**: `from(t: T) -> T` * **Endpoint**: N/A (Trait implementation) * **Parameters**: * **Request Body**: * `t` (T) - Required - The value to convert. * **Response**: * **Success Response (200)**: * `T` - The original value, unchanged. ### `impl Identity for T` * **Description**: Provides a proof of type equality (`TypeEq`) and allows for type-level equality checks. * **Associated Types**: * `Type = T`: Represents the same type as `Self`. * **Constants**: * `TYPE_EQ: TypeEq::Type>`: A constant providing proof of type equality. ### `impl Into for T` * **Description**: Allows conversion from type `T` to type `U` if `U` implements `From`. * **Method**: `into(self) -> U` * **Endpoint**: N/A (Trait implementation) * **Parameters**: * **Request Body**: * `self` (T) - Required - The value to convert. * **Response**: * **Success Response (200)**: * `U` - The converted value. ### `impl TryFrom for T` * **Description**: Enables fallible conversion from type `U` to type `T`. * **Associated Types**: * `Error = Infallible`: The error type for conversion failures (in this specific case, it's infallible). * **Method**: `try_from(value: U) -> Result>::Error>` * **Endpoint**: N/A (Trait implementation) * **Parameters**: * **Request Body**: * `value` (U) - Required - The value to attempt conversion from. * **Response**: * **Success Response (200)**: * `T` - The successfully converted value. * **Error Response**: `Infallible` - If conversion fails (though this specific impl is infallible). ### `impl TryInto for T` * **Description**: Enables fallible conversion from type `T` to type `U` if `U` implements `TryFrom`. * **Associated Types**: * `Error = >::Error`: The error type from the corresponding `TryFrom` implementation. * **Method**: `try_into(self) -> Result>::Error>` * **Endpoint**: N/A (Trait implementation) * **Parameters**: * **Request Body**: * `self` (T) - Required - The value to attempt conversion from. * **Response**: * **Success Response (200)**: * `U` - The successfully converted value. * **Error Response**: `>::Error` - If conversion fails. ``` -------------------------------- ### Get Type Witness Constant Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/cbor/struct.CborAssetSaver_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides a constant of the type witness, used for type-level programming and ensuring type equality constraints. ```rust const WITNESS: W = W::MAKE where W: MakeTypeWitness, T: ?Sized, ``` -------------------------------- ### Settings Trait Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/ron/struct.RonAssetLoader_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Documentation for the Settings trait. ```APIDOC ## Settings Trait ### `impl Settings for T` - **Description**: A trait for types that can be used as settings. - **Constraints**: `where T: 'static + Send + Sync` ``` -------------------------------- ### Converting Value to String Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/toml/enum.TomlLoaderError_search=u32+-%3E+bool Converts a value that implements the Display trait into its String representation. This is a standard way to get a string from various data types. ```rust fn to_string(&self) -> String ``` -------------------------------- ### Conversion Utilities Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/ron/struct.RonAssetLoader_search=std%3A%3Avec Provides various conversion utilities including Into, TryFrom, and TryInto. ```APIDOC ## POST /conversion/into ### Description Converts the input type `T` into type `U` using the `From` implementation for `U`. ### Method POST ### Endpoint /conversion/into #### Request Body - **value** (T) - Required - The value to convert. ### Response #### Success Response (200) - **converted_value** (U) - The converted value. ## POST /conversion/try-from ### Description Attempts to perform a conversion from type `U` into type `T`. ### Method POST ### Endpoint /conversion/try-from #### Request Body - **value** (U) - Required - The value to attempt conversion from. ### Response #### Success Response (200) - **converted_value** (T) - The successfully converted value. #### Error Response (400) - **error** (Infallible) - The error encountered during conversion. ## POST /conversion/try-into ### Description Attempts to perform a conversion from type `T` into type `U`. ### Method POST ### Endpoint /conversion/try-into #### Request Body - **value** (T) - Required - The value to attempt conversion into. ### Response #### Success Response (200) - **converted_value** (U) - The successfully converted value. #### Error Response (400) - **error** (>::Error) - The error encountered during conversion. ``` -------------------------------- ### Settings Trait Implementations Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/ron/struct.RonAssetPlugin_search= Documentation for the `Settings` trait, likely for configuration management. ```APIDOC ## Settings for T ### Description Trait for types that represent settings, requiring `'static`, `Send`, and `Sync` bounds. ### Method N/A (Trait marker) ### Endpoint N/A (Trait Implementation) ### Parameters None ### Request Example ```rust // This trait is often used for configuration or global settings. struct GameSettings; impl Settings for GameSettings { /* ... */ } ``` ### Response #### Success Response N/A (Trait marker) #### Response Example N/A (Trait Implementation) ``` -------------------------------- ### Get AssetSaver Type Name Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/cbor/struct.CborAssetSaver Retrieves the static string representing the type name of the AssetSaver. This is a simple function that returns a string slice. ```rust fn type_name(&self) -> &'static str ``` -------------------------------- ### Converting to String in Rust Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/cbor/enum.CborAssetError_search=std%3A%3Avec This implementation of the `ToString` trait allows converting any type that implements `Display` into a `String`. It provides a standard way to get a string representation of a value. ```rust fn to_string(&self) -> String Converts the given value to a `String`. ``` -------------------------------- ### Create CborAssetPlugin Instance Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/cbor/struct.CborAssetPlugin_search=std%3A%3Avec Provides a constructor function `new` for `CborAssetPlugin`. This function takes a slice of static string slices representing file extensions and returns a new instance of the plugin, configured to load assets with those extensions. ```rust pub fn new(extensions: &[&'static str]) -> Self ``` -------------------------------- ### Get Type Witness (Rust) Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/postcard/struct.PostcardAssetSaver_search=u32+-%3E+bool Provides a constant type witness for generic programming. This is used to establish type equality or relationships between types in a statically verifiable way. ```rust const WITNESS: W = W::MAKE where W: MakeTypeWitness, T: ?Sized ``` -------------------------------- ### Conversion Traits API Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/csv/struct.LoadedCsv_search=std%3A%3Avec Documentation for various conversion traits like Into, TryFrom, and TryInto. ```APIDOC ## Conversion Traits ### Description This section details the conversion capabilities provided by the `Into`, `TryFrom`, and `TryInto` traits. ### `Into` Trait #### Method `into(self) -> U` #### Description Calls `U::from(self)`. This conversion is defined by the specific implementation of `From for U`. ### `TryFrom` Trait #### Type Alias `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. ### `TryInto` Trait #### Type Alias `type Error = >::Error` #### Description The type returned in the event of a conversion error. #### Method `try_into(self) -> Result>::Error>` #### Description Performs the conversion. ``` -------------------------------- ### System and Conditional Traits Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/toml/struct.TomlAssetLoader Documentation for traits related to system execution and conditional sending. ```APIDOC ## System and Conditional Traits ### Description This section covers traits for system execution conversions and conditional thread safety. ### `impl IntoResult for T` * **Description**: Converts the type into a `Result` suitable for system execution outcomes. * **Method**: `into_result(self) -> Result` * **Endpoint**: N/A (Trait implementation) * **Parameters**: * **Request Body**: * `self` (T) - Required - The value to convert. * **Response**: * **Success Response (200)**: * `Result` - The value wrapped in `Ok` or an error wrapped in `Err`. ### `impl Is for A` * **Description**: Provides a method to check if a type is another specific type using `TypeId` comparison. * **Method**: `is() -> bool` * **Endpoint**: N/A (Trait implementation) * **Parameters**: * **Query Parameters**: * `T` (Type) - Required - The type to check against. * **Response**: * **Success Response (200)**: * `bool` - `true` if the type matches `T`, `false` otherwise. ### `impl ConditionalSend for T` * **Description**: A marker trait indicating that a type is `Send` (safe to send across threads). * **Constraints**: * `T: Send` * **Endpoint**: N/A (Trait implementation) ### `impl Settings for T` * **Description**: A marker trait for types that represent settings, typically with static lifetime and thread safety guarantees. * **Constraints**: * `T: 'static + Send + Sync` * **Endpoint**: N/A (Trait implementation) ``` -------------------------------- ### Implement Plugin Trait for TomlAssetPlugin Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/toml/struct.TomlAssetPlugin_search=std%3A%3Avec Implements the Plugin trait for TomlAssetPlugin, enabling its integration into a Bevy application. This includes methods for building, checking readiness, finishing setup, and cleanup. ```rust impl Plugin for TomlAssetPlugin where for<'de> A: Deserialize<'de> + Asset, { fn build(&self, app: &mut App) { // Configures the `App` to which this plugin is added. } fn ready(&self, _app: &App) -> bool { // Has the plugin finished its setup? true } fn finish(&self, _app: &mut App) { // Finish adding this plugin to the `App`. } fn cleanup(&self, _app: &mut App) { // Runs after all plugins are built and finished. } fn name(&self) -> &str { // Configures a name for the `Plugin`. "TomlAssetPlugin" } fn is_unique(&self) -> bool { // If the plugin can be meaningfully instantiated several times in an `App`. true } } ``` -------------------------------- ### Implement Bevy Plugin Build Method for CborAssetPlugin Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/cbor/struct.CborAssetPlugin_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Implements the 'build' method for the CborAssetPlugin, which is part of the Bevy game engine's plugin system. This method configures the Bevy application ('App') by adding the necessary systems and resources for loading CBOR assets. ```rust fn build(&self, app: &mut App) ``` -------------------------------- ### Implement Plugin Trait for CsvAssetPlugin Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/csv/struct.CsvAssetPlugin_search=std%3A%3Avec Provides the implementation of the Plugin trait for CsvAssetPlugin, allowing it to be added to a Bevy App. This includes methods for building, checking readiness, finishing setup, and cleanup. ```rust impl Plugin for CsvAssetPlugin where for<'de> A: Deserialize<'de> + Asset, { fn build(&self, app: &mut App) { // Plugin build logic } fn ready(&self, _app: &App) -> bool { // Readiness check true } fn finish(&self, _app: &mut App) { // Plugin finish logic } fn cleanup(&self, _app: &mut App) { // Plugin cleanup logic } fn name(&self) -> &str { // Plugin name std::any::type_name::() } fn is_unique(&self) -> bool { // Uniqueness check true } } ``` -------------------------------- ### Type Conversion and Witness Implementations Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/msgpack/struct.MsgPackAssetLoader_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Documentation for various type conversion and witness implementations, including identity, instrumentation, and try-from/into traits. ```APIDOC ## Type Conversion and Witness Implementations ### Description Documentation for various type conversion and witness implementations, including identity, instrumentation, and try-from/into traits. ### `impl From for T` * **Description**: Returns the argument unchanged. * **Method**: N/A (Implementation detail) ### `impl HasTypeWitness for T` * **Description**: Provides a type witness for generic programming. * **Constant**: `WITNESS: W = W::MAKE` - A constant of the type witness. ### `impl Identity for T` * **Description**: Provides a proof of type equality and methods for casting. * **Constant**: `TYPE_EQ: TypeEq::Type> = TypeEq::NEW` - Proof that `Self` is the same type as `Self::Type`. * **Associated Type**: `Type = T` - The same type as `Self`. ### `impl Instrument for T` * **Description**: Allows instrumenting types with spans for tracing. * **Methods**: * `instrument(self, span: Span) -> Instrumented` - Instruments this type with the provided `Span`. * `in_current_span(self) -> Instrumented` - Instruments this type with the current `Span`. ### `impl Into for T` * **Description**: Converts `self` into type `U` if `U` implements `From`. * **Method**: `into(self) -> U` - Calls `U::from(self)`. ### `impl IntoEither for T` * **Description**: Converts `self` into either the `Left` or `Right` variant of `Either`. * **Methods**: * `into_either(self, into_left: bool) -> Either` - Converts based on the `into_left` boolean. * `into_either_with(self, into_left: F) -> Either` - Converts based on the result of the provided closure `F`. ### `impl IntoResult for T` * **Description**: Converts this type into the system output type `Result`. * **Method**: `into_result(self) -> Result`. ### `impl Is for A` * **Description**: Checks if the current type "is" another type using `TypeId` equality. * **Method**: `is() -> bool` - Checks if the type is `T`. ### `impl TryFrom for T` * **Description**: Provides fallible conversion from type `U` to type `T`. * **Associated Type**: `Error = Infallible` - The type returned on conversion error. * **Method**: `try_from(value: U) -> Result>::Error>`. ### `impl TryInto for T` * **Description**: Provides fallible conversion from type `T` to type `U`. * **Associated Type**: `Error = >::Error` - The type returned on conversion error. * **Method**: `try_into(self) -> Result>::Error>`. ### `impl WithSubscriber for T` * **Description**: Attaches a subscriber to the type. * **Methods**: * `with_subscriber(self, subscriber: S) -> WithDispatch` - Attaches the provided `Subscriber`. * `with_current_subscriber(self) -> WithDispatch` - Attaches the current default `Subscriber`. ### `impl ConditionalSend for T` * **Description**: Indicates that `T` implements `Send`. ### `impl Settings for T` * **Description**: Associated with settings for types that are `'static + Send + Sync`. ``` -------------------------------- ### Conversion Utilities Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/toml/enum.TomlLoaderError Utilities for converting between different types, including `Into`, `TryFrom`, and `TryInto` implementations. ```APIDOC ## Conversion Utilities ### Description Provides various methods for converting between types, including standard library traits and custom implementations. ### Methods #### `into(self) -> U` (from `Into for T`) Calls `U::from(self)`. This conversion is determined by the `From for U` implementation. #### `try_from(value: U) -> Result>::Error>` (from `TryFrom for T`) Performs a fallible conversion from type `U` to type `T`. #### `try_into(self) -> Result>::Error>` (from `TryInto for T`) Performs a fallible conversion from type `T` to type `U`. ### Request Example ```json { "example": "No direct request body. These are trait methods called on existing types." } ``` ### Response #### Success Response (200) - **Converted Type** (type) - The resulting type after a successful conversion. - **Result** (type) - For fallible conversions, a `Result` indicating success or failure. #### Response Example ```json { "example": "Converted value or Ok(value) / Err(error)" } ``` ``` -------------------------------- ### Asset Loader Metadata and Type Information Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/postcard/struct.PostcardAssetLoader_search=u32+-%3E+bool Provides methods to retrieve supported file extensions, deserialize metadata from bytes, get default metadata, and obtain type path and ID information for an AssetLoader. ```rust fn extensions(&self) -> &[&str] fn deserialize_meta( &self, meta: &[u8], ) -> Result, DeserializeMetaError> fn default_meta(&self) -> Box fn type_path(&self) -> &'static str fn type_id(&self) -> TypeId fn asset_type_name(&self) -> &'static str fn asset_type_id(&self) -> TypeId ``` -------------------------------- ### Get Type Witness for HasTypeWitness Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/cbor/struct.CborAssetSaver Implements the HasTypeWitness trait for a generic type T with a type witness W. The 'WITNESS' constant provides a type witness, useful for generic programming and type-level operations. ```rust const WITNESS: W = W::MAKE ``` -------------------------------- ### Conversion and Identity Traits Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/xml/struct.XmlAssetLoader Documentation for traits related to type conversion and identity, including `From`, `Into`, `TryFrom`, `TryInto`, and `Identity`. ```APIDOC ## Conversion and Identity Traits ### Description Traits for handling type conversions and establishing type identity. ### Traits - `impl From for T` - `fn from(t: T) -> T`: Returns the argument unchanged. - `impl Into for T where U: From` - `fn into(self) -> U`: Calls `U::from(self)`. - `impl TryFrom for T where U: Into` - `type Error = Infallible` - `fn try_from(value: U) -> Result>::Error>`: Performs the conversion. - `impl TryInto for T where U: TryFrom` - `type Error = >::Error` - `fn try_into(self) -> Result>::Error>`: Performs the conversion. - `impl Identity for T where T: ?Sized` - `const TYPE_EQ: TypeEq::Type> = TypeEq::NEW`: Proof that `Self` is the same type as `Self::Type`. - `type Type = T`: The same type as `Self`. ``` -------------------------------- ### Type Conversions (TryFrom/TryInto) Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/msgpack/struct.MsgPackAssetPlugin_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides methods for attempting type conversions that may fail. ```APIDOC ## `TryFrom` and `TryInto` ### Description Provides methods for attempting conversions between types that may fail, returning a `Result`. ### Method `T::try_from(value: U)` or `value.try_into()` ### Endpoint N/A (Trait implementation) ### Parameters - `value` (U): The value to convert from. ### Request Example ```rust // Assuming 'SourceType' can be tried into 'TargetType' try { let target_value: TargetType = source_value.try_into()?; } catch (e) { // Handle conversion error } ``` ### Response #### Success Response - `Result>::Error>`: A `Result` containing the converted type on success, or an error on failure. #### Response Example ```json // This is a conceptual representation, actual return is a Rust type { "type": "Result", "status": "Ok" or "Err", "value": "converted_value" or "error_details" } ``` ``` -------------------------------- ### Implement TypePath for CborAssetSaver in Rust Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/cbor/struct.CborAssetSaver Implements the TypePath trait for CborAssetSaver, providing methods to get the type's path information. This is useful for reflection and type identification within the Bevy engine. ```rust impl TypePath for CborAssetSaver where CborAssetSaver: Any + Send + Sync, A: TypePath, { fn type_path() -> &'static str { // Implementation details for type path } fn short_type_path() -> &'static str { // Implementation details for short type path } fn type_ident() -> Option<&'static str> { // Implementation details for type identifier } fn crate_name() -> Option<&'static str> { // Implementation details for crate name } fn module_path() -> Option<&'static str> { // Implementation details for module path } } ``` -------------------------------- ### Implement Plugin trait for CsvAssetPlugin Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/csv/struct.CsvAssetPlugin_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides the standard Bevy Plugin trait implementations for CsvAssetPlugin. This includes methods for building, checking readiness, finishing setup, and cleanup of the plugin within a Bevy App. ```rust impl where for<'de> A: Deserialize<'de> + Asset, { fn build(&self, app: &mut App); fn ready(&self, _app: &App) -> bool; fn finish(&self, _app: &mut App); fn cleanup(&self, _app: &mut App); fn name(&self) -> &str; fn is_unique(&self) -> bool; } ``` -------------------------------- ### Instrumentation and Subscribers Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/xml/struct.XmlAssetLoader Documentation for traits related to instrumentation and managing subscribers. ```APIDOC ## Instrumentation and Subscribers ### Description Traits for instrumenting types with spans and attaching subscribers. ### Traits - `impl Instrument for T` - `fn instrument(self, span: Span) -> Instrumented`: Instruments this type with the provided `Span`. - `fn in_current_span(self) -> Instrumented`: Instruments this type with the current `Span`. - `impl WithSubscriber for T` - `fn with_subscriber(self, subscriber: S) -> WithDispatch where S: Into`: Attaches the provided `Subscriber` to this type. - `fn with_current_subscriber(self) -> WithDispatch`: Attaches the current default `Subscriber` to this type. ``` -------------------------------- ### Type Conversion and Transformation Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/toml/struct.TomlAssetLoader_search=std%3A%3Avec Handles type conversions, including `From`, `Into`, `TryFrom`, and `TryInto`. ```APIDOC ## POST /convert/into ### Description Converts a value from one type to another using the `Into` trait. ### Method POST ### Endpoint /convert/into #### Request Body - **value** (any) - Required - The value to convert. - **target_type** (string) - Required - The target type for conversion. ### Request Example ```json { "value": "some_value", "target_type": "TargetType" } ``` #### Success Response (200) - **converted_value** (any) - The converted value. #### Response Example ```json { "converted_value": "converted_value_details" } ``` ## POST /convert/try_into ### Description Attempts to convert a value from one type to another using the `TryInto` trait. ### Method POST ### Endpoint /convert/try_into #### Request Body - **value** (any) - Required - The value to convert. - **target_type** (string) - Required - The target type for conversion. ### Request Example ```json { "value": "some_value", "target_type": "TargetType" } ``` #### Success Response (200) - **converted_value** (any) - The converted value. #### Error Response (400) - **error** (string) - The error message if conversion fails. #### Response Example ```json { "converted_value": "converted_value_details" } ``` ``` -------------------------------- ### Plugins Implementation Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/msgpack/struct.MsgPackAssetPlugin_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Indicates that a type can manage plugins for a specific marker. ```APIDOC ## `Plugins` ### Description Trait for types that can manage plugins associated with a specific `Marker` type. ### Method N/A (Trait implementation) ### Endpoint N/A (Trait implementation) ### Parameters - `Marker` (Generic Type): A marker type to associate plugins with. ### Request Example ```rust // If a type T implements Plugins, it can manage plugins for MyMarker struct MyPluginManager; impl Plugins for MyPluginManager { // ... plugin management methods } ``` ### Response #### Success Response - N/A (This is a trait bound, not a return value) #### Response Example ```json { "trait": "Plugins", "description": "Manages plugins for a specific marker type" } ``` ``` -------------------------------- ### Conditional Send and Settings Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/xml/struct.XmlAssetLoader Documentation for traits related to conditional sending and settings. ```APIDOC ## Conditional Send and Settings ### Description Traits for defining conditional sendability and accessing settings. ### Traits - `impl ConditionalSend for T where T: Send` - No methods defined, indicates `T` satisfies the `Send` trait. - `impl Settings for T where T: 'static + Send + Sync` - No methods defined, indicates `T` has associated settings. ``` -------------------------------- ### PostcardAssetLoader TypePath Implementation Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/postcard/struct.PostcardAssetLoader Implements the TypePath trait for PostcardAssetLoader, providing methods to get the fully qualified path, short path, identifier, crate name, and module path of the type. This is useful for reflection and type introspection within Bevy. ```rust impl TypePath for PostcardAssetLoader where PostcardAssetLoader: Any + Send + Sync, A: TypePath, { fn type_path() -> &'static str { // Implementation to return the type path unimplemented!(); } fn short_type_path() -> &'static str { // Implementation for short type path unimplemented!(); } fn type_ident() -> Option<&'static str> { // Implementation for type identifier unimplemented!(); } fn crate_name() -> Option<&'static str> { // Implementation for crate name unimplemented!(); } fn module_path() -> Option<&'static str> { // Implementation for module path unimplemented!(); } } ``` -------------------------------- ### Settings Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/msgpack/enum.MsgPackLoaderError_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Represents settings for a type that is 'static, Send, and Sync. ```APIDOC ## Settings Trait ### Description This trait is implemented for types that are `'static`, `Send`, and `Sync`, typically used for configuration or settings. ### Method N/A (Trait Definition) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### MsgPackAssetPlugin Plugin Trait Implementation Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/msgpack/struct.MsgPackAssetPlugin_search=u32+-%3E+bool Implements the Bevy Plugin trait for MsgPackAssetPlugin. This includes methods for building the app, checking readiness, finishing setup, cleanup, and naming the plugin. The generic type 'A' must implement Deserialize and Asset traits. ```rust impl Plugin for MsgPackAssetPlugin where for<'de> A: Deserialize<'de> + Asset, { fn build(&self, app: &mut App) { // ... implementation details ... } fn ready(&self, _app: &App) -> bool { // ... implementation details ... true } fn finish(&self, _app: &mut App) { // ... implementation details ... } fn cleanup(&self, _app: &mut App) { // ... implementation details ... } fn name(&self) -> &str { // ... implementation details ... "MsgPackAssetPlugin" } fn is_unique(&self) -> bool { // ... implementation details ... true } } ``` -------------------------------- ### Implement TypePath for CsvAssetLoader Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/csv/struct.CsvAssetLoader_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Implements the TypePath trait for CsvAssetLoader, providing methods to get the fully qualified path, short path, identifier, crate name, and module path of the type. This is useful for reflection and type introspection within the Bevy engine. ```rust impl TypePath for CsvAssetLoader where CsvAssetLoader: Any + Send + Sync, A: TypePath, { fn type_path() -> &'static str { // Returns the fully qualified path of the type unimplemented!() } fn short_type_path() -> &'static str { // Returns a short, pretty-print enabled path to the type unimplemented!() } fn type_ident() -> Option<&'static str> { // Returns the name of the type, or None if it is anonymous unimplemented!() } fn crate_name() -> Option<&'static str> { // Returns the name of the crate the type is in, or None if it is anonymous unimplemented!() } fn module_path() -> Option<&'static str> { // Returns the path to the module the type is in, or None if it is anonymous unimplemented!() } } ``` -------------------------------- ### XmlAssetPlugin Source: https://docs.rs/bevy_common_assets/0.15.0/bevy_common_assets/xml/struct.XmlAssetPlugin Plugin to load your asset type A from xml files. Read the quick_xml docs for tips on deserialization. ```APIDOC ## Struct XmlAssetPlugin ### Description Plugin to load your asset type `A` from xml files. Read the `quick_xml` docs for tips on deserialization. Available on **crate feature `xml`** only. ### Generic Parameters * `A`: The asset type to be loaded from XML files. Must implement `Deserialize` and `Asset`. ### Methods #### `new(extensions: &[&'static str]) -> Self` Create a new plugin that will load assets from files with the given extensions. ### Trait Implementations #### `Plugin` ##### `build(&self, app: &mut App)` Configures the `App` to which this plugin is added. ##### `ready(&self, _app: &App) -> bool` Has the plugin finished its setup? This can be useful for plugins that need something asynchronous to happen before they can finish their setup, like the initialization of a renderer. Once the plugin is ready, `finish` should be called. ##### `finish(&self, _app: &mut App)` Finish adding this plugin to the `App`, once all plugins registered are ready. This can be useful for plugins that depends on another plugin asynchronous setup, like the renderer. ##### `cleanup(&self, _app: &mut App)` Runs after all plugins are built and finished, but before the app schedule is executed. This can be useful if you have some resource that other plugins need during their build step, but after build you want to remove it and send it to another thread. ##### `name(&self) -> &str` Configures a name for the `Plugin` which is primarily used for checking plugin uniqueness and debugging. ##### `is_unique(&self) -> bool` If the plugin can be meaningfully instantiated several times in an `App`, override this method to return `false`. ```