### Using leptos_icons with icondata in Leptos Source: https://docs.rs/leptos_icons/0.7.0/src/leptos_icons/lib Demonstrates how to include leptos_icons and icondata in your Cargo.toml and how to use the Icon component within a Leptos view. It shows a basic example of rendering an icon. ```toml [dependencies] leptos_icons = { version = "{crate_version}" } icondata = { version = "{icondata_version}" } ``` ```rust use leptos::prelude::*; use leptos_icons::Icon; #[cfg(target_arch = "wasm32")] let _ = view! { }; ``` -------------------------------- ### Render an Icon Component in Leptos Source: https://docs.rs/leptos_icons/0.7.0/index This example demonstrates how to use the 'Icon' component from the 'leptos_icons' crate within a Leptos project. It imports necessary items and renders an icon using a symbol from the 'icondata' crate. ```rust use leptos::prelude::*; use leptos_icons::Icon; let _ = view! { }; ``` -------------------------------- ### Render an Icon using Leptos Icons Component Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons This example demonstrates how to use the `Icon` component from the leptos_icons crate within a Leptos view. It requires importing `leptos::prelude::*` and `leptos_icons::Icon`, and uses an icon from the `icondata` crate (e.g., `BsFolder`). ```rust use leptos::prelude::*; use leptos_icons::Icon; let _ = view! { }; ``` -------------------------------- ### Using Symbol Component for Reusable Icons Source: https://docs.rs/leptos_icons/0.7.0/src/leptos_icons/lib An example demonstrating how to use the `Symbol` component to define an icon with a specific ID. It then shows how to reference this defined icon using an SVG `` element, enabling reusable icon components. ```rust use leptos::prelude::*; use leptos_icons::Symbol; #[component] fn MyComponent() -> impl IntoView { view! { } } ``` -------------------------------- ### Add Leptos Icons and Icondata Dependencies Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons This snippet shows how to add the leptos_icons and icondata crates to your project's Cargo.toml file. Ensure you replace '{crate_version}' and '{icondata_version}' with the actual versions you are using. ```toml [dependencies] leptos_icons = { version = "{crate_version}" } icondata = { version = "{icondata_version}" } ``` -------------------------------- ### Create IconProps Builder in Rust Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct Provides a builder pattern for constructing IconProps instances. This method allows for setting the icon and optional properties like style, width, and height in a fluent manner before building the final struct. It's a common pattern for complex struct initialization. ```rust pub fn builder() -> IconPropsBuilder<((), (), (), ())> Create a builder for building `IconProps`. On the builder, call `.icon(...)`, `.style(...)`(optional), `.width(...)`(optional), `.height(...)`(optional) to set the values of the fields. Finally, call `.build()` to create the instance of `IconProps`. ``` -------------------------------- ### Leptos Icon Component Implementation Source: https://docs.rs/leptos_icons/0.7.0/src/leptos_icons/lib The core implementation of the `Icon` component in leptos_icons. It takes an `icondata_core::Icon` and renders it as an SVG element, supporting various attributes for styling and sizing. ```rust use leptos::{prelude::*, svg}; /// The Icon component. #[component] pub fn Icon( /// The icon to render. #[prop(into)] icon: Signal, #[prop(into, optional)] style: MaybeProp, #[prop(into, optional)] width: MaybeProp, #[prop(into, optional)] height: MaybeProp, ) -> impl IntoView { move || { let icon = icon.get(); svg::svg() .style(match (style.get(), icon.style) { (Some(a), Some(b)) => Some(format!("{b} {a}")), (Some(a), None) => Some(a), (None, Some(b)) => Some(b.to_string()), _ => None, }) .attr("x", icon.x) .attr("y", icon.y) .attr("width", width.get().unwrap_or_else(|| "1em".to_string())) .attr("height", height.get().unwrap_or_else(|| "1em".to_string())) .attr("viewBox", icon.view_box) .attr("stroke-linecap", icon.stroke_linecap) .attr("stroke-linejoin", icon.stroke_linejoin) .attr("stroke-width", icon.stroke_width) .attr("stroke", icon.stroke) .attr("fill", icon.fill.unwrap_or("currentColor")) .attr("role", "graphics-symbol") .child(svg::InertElement::new(icon.data)) } } ``` -------------------------------- ### Leptos Symbol Component Implementation Source: https://docs.rs/leptos_icons/0.7.0/src/leptos_icons/lib The implementation of the `Symbol` component in leptos_icons. It creates an SVG `` element, which can be referenced using `` elements for icon definitions, and includes basic styling and icon attributes. ```rust use leptos::{prelude::*, svg}; /// Creates a `` with the icon. #[component] pub fn Symbol( /// Id of the symbol for later refernce. /// Used as the `href` property in a `` element. #[prop(into)] id: String, /// The icon to render. #[prop(into)] icon: Signal, #[prop(into, optional)] style: MaybeProp, ) -> impl IntoView { move || { let icon = icon.get(); let sym = svg::symbol() .style(match (style.get(), icon.style) { (Some(a), Some(b)) => Some(format!("{b} {a}")), (Some(a), None) => Some(a), (None, Some(b)) => Some(b.to_string()), _ => None, }) .attr("id", id.clone()) .attr("x", icon.x) .attr("y", icon.y) .attr("viewBox", icon.view_box) .attr("stroke-linecap", icon.stroke_linecap) .attr("stroke-linejoin", icon.stroke_linejoin) .attr("stroke-width", icon.stroke_width) .attr("stroke", icon.stroke) .attr("fill", icon.fill.unwrap_or("currentColor")) .attr("role", "graphics-symbol") .child(svg::InertElement::new(icon.data)); svg::svg().style("display: none;").child(sym) } } ``` -------------------------------- ### IntoReq for POST Requests Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct Provides functionality to convert data into a POST HTTP request. This is useful for sending data to the server for processing. ```APIDOC ## POST /api/request ### Description Attempts to serialize the arguments into an HTTP POST request. ### Method POST ### Endpoint /api/request ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **self** (T) - Required - The data to be serialized into the request. - **path** (str) - Required - The endpoint path for the request. - **accepts** (str) - Required - The expected content type of the response. ### Request Example ```json { "data": "...", "path": "/submit_icon_data", "accepts": "application/json" } ``` ### Response #### Success Response (200) - **Request** (Request) - The constructed HTTP request object. #### Response Example ```json { "status": "success", "request_details": { "method": "POST", "url": "/submit_icon_data" } } ``` ``` -------------------------------- ### TryFrom Trait Implementation Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct Implements the `TryFrom` trait for conversion between types, allowing for fallible conversions. ```APIDOC ## Trait: TryFrom for T ### Description Implements fallible type conversion from type `U` to type `T`. ### Associated Types #### type Error = Infallible The error type returned when conversion fails. In this case, it's `Infallible`, indicating conversion should not fail. ### Methods #### fn try_from(value: U) -> Result>::Error> Attempts to convert the `value` of type `U` into type `T`. ``` -------------------------------- ### IntoReq for PUT Requests Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct Provides functionality to convert data into a PUT HTTP request. This is typically used for updating existing resources on the server. ```APIDOC ## PUT /api/request ### Description Attempts to serialize the arguments into an HTTP PUT request. ### Method PUT ### Endpoint /api/request ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **self** (T) - Required - The data to be serialized into the request. - **path** (str) - Required - The endpoint path for the request. - **accepts** (str) - Required - The expected content type of the response. ### Request Example ```json { "data": "...", "path": "/update_icon_data/123", "accepts": "application/json" } ``` ### Response #### Success Response (200) - **Request** (Request) - The constructed HTTP request object. #### Response Example ```json { "status": "success", "request_details": { "method": "PUT", "url": "/update_icon_data/123" } } ``` ``` -------------------------------- ### Implement IntoReq for Post Requests in Rust Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct This implementation allows types to be converted into HTTP POST requests. It handles serialization of arguments into the request, requiring a client request implementation and an encoding mechanism. ```rust impl IntoReq, Request, E> for T where Request: ClientReq, Encoding: Encodes, E: FromServerFnError, Source§ #### fn into_req(self, path: &str, accepts: &str) -> Result ``` -------------------------------- ### StorageAccess Trait Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct Defines a trait for accessing and managing stored data, allowing for both borrowing and taking ownership. ```APIDOC ## Trait: StorageAccess ### Description Provides methods for accessing stored data, allowing for immutable borrowing or transferring ownership. ### Methods #### fn as_borrowed(&self) -> &T Borrows the stored value immutably. #### fn into_taken(self) -> T Consumes the storage and returns the owned value. ### Usage Example ```rust let mut storage = vec![1, 2, 3]; let borrowed_data = storage.as_borrowed(); println!("Borrowed data: {:?}", borrowed_data); let taken_data = storage.into_taken(); println!("Taken data: {:?}", taken_data); ``` ``` -------------------------------- ### Create SVG Symbol with Icon (Rust/Leptos) Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/fn Defines and creates an SVG element using the Symbol component from leptos_icons. This component takes an icon and an ID to render the icon data, which can then be referenced using an SVG element. It requires an 'id' and an 'icon' prop, with an optional 'style' prop. ```rust pub fn Symbol(props: SymbolProps) -> impl IntoView // Example Usage: use leptos::prelude::*; use leptos_icons::Symbol; #[component] fn MyComponent() -> impl IntoView { view! { } } ``` -------------------------------- ### TryInto Trait Implementation Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct Implements the `TryInto` trait for fallible conversion into other types. ```APIDOC ## Trait: TryInto for T ### Description Implements fallible type conversion from type `T` into type `U`. ### Associated Types #### type Error = >::Error The error type returned when conversion fails, delegated from the `TryFrom` implementation for `U`. ### Methods #### fn try_into(self) -> Result>::Error> Attempts to convert `self` (type `T`) into type `U`. ``` -------------------------------- ### IntoRes for PATCH Requests Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct Provides functionality to convert data into a PATCH HTTP response. This is used for partially updating resources. ```APIDOC ## PATCH /api/response ### Description Attempts to serialize the output into an HTTP PATCH response. ### Method PATCH ### Endpoint /api/response ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **self** (T) - Required - The data to be serialized into the response. ### Request Example ```json { "updates": { "color": "blue" } } ``` ### Response #### Success Response (200) - **Response** (Response) - The constructed HTTP response object. #### Response Example ```json { "status": "success", "message": "Resource partially updated." } ``` ``` -------------------------------- ### Implement IntoReq for Put Requests in Rust Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct This implementation enables types to be transformed into HTTP PUT requests. It manages the serialization of parameters into the request, dependent on a client request interface and an encoding strategy. ```rust impl IntoReq, Request, E> for T where Request: ClientReq, Encoding: Encodes, E: FromServerFnError, Source§ #### fn into_req(self, path: &str, accepts: &str) -> Result ``` -------------------------------- ### Implement IntoReq for IconProps in Rust Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct Illustrates the implementation of the `IntoReq` trait for serializing `IconProps` into an HTTP request. This is crucial for sending component props or data to a server, particularly in the context of Leptos' server functions. ```rust fn into_req(self, path: &str, accepts: &str) -> Result Attempts to serialize the arguments into an HTTP request. ``` -------------------------------- ### Implement TryInto for Type Conversion in Rust Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct This standard Rust trait is the inverse of `TryFrom`. It allows attempting to convert a value into another type, returning a `Result` with a potential error. ```rust impl TryInto for T where U: TryFrom, Source§ #### type Error = >::Error #### fn try_into(self) -> Result>::Error> ``` -------------------------------- ### IntoRes for POST Responses Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct Provides functionality to convert data into a POST HTTP response. This is used to send back results after a POST operation. ```APIDOC ## POST /api/response ### Description Attempts to serialize the output into an HTTP POST response. ### Method POST ### Endpoint /api/response ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **self** (T) - Required - The data to be serialized into the response. ### Request Example ```json { "result": "operation successful" } ``` ### Response #### Success Response (200) - **Response** (Response) - The constructed HTTP response object. #### Response Example ```json { "status": "success", "data": { "result": "operation successful" } } ``` ``` -------------------------------- ### Implement SerializableKey for Key Serialization in Rust Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct This implementation provides a method to serialize any type implementing this trait into a unique string representation. This is useful for creating keys in data structures or caches. ```rust impl SerializableKey for T Source§ #### fn ser_key(&self) -> String ``` -------------------------------- ### Implement StorageAccess for Data Borrowing and Taking in Rust Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct This trait offers methods for accessing data stored within a type. It allows for borrowing a reference to the data (`as_borrowed`) or taking ownership of the data (`into_taken`). ```rust impl StorageAccess for T Source§ #### fn as_borrowed(&self) -> &T #### fn into_taken(self) -> T ``` -------------------------------- ### IntoRes for PUT Responses Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct Provides functionality to convert data into a PUT HTTP response. This is used to send back results after a PUT operation. ```APIDOC ## PUT /api/response ### Description Attempts to serialize the output into an HTTP PUT response. ### Method PUT ### Endpoint /api/response ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **self** (T) - Required - The data to be serialized into the response. ### Request Example ```json { "updated_data": {"field": "value"} } ``` ### Response #### Success Response (200) - **Response** (Response) - The constructed HTTP response object. #### Response Example ```json { "status": "success", "message": "Resource updated successfully.", "data": { "updated_data": {"field": "value"} } } ``` ``` -------------------------------- ### Implement IntoRes for Post Responses in Rust Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct This implementation allows types to be serialized into HTTP POST responses. It requires a compatible response type, an encoder, and ensures that the types involved are Send and can handle potential errors. ```rust impl IntoRes, Response, E> for T where Response: TryRes, Encoding: Encodes, E: FromServerFnError + Send, T: Send, Source§ #### async fn into_res(self) -> Result ``` -------------------------------- ### Define IconProps Struct in Rust Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct Defines the structure for IconProps, which holds properties for the Icon component. It includes required and optional fields like the icon itself, style, width, and height. This struct is fundamental for configuring icon rendering in Leptos. ```rust pub struct IconProps { pub icon: Signal, pub style: MaybeProp, pub width: MaybeProp, pub height: MaybeProp, } ``` -------------------------------- ### SerializableKey Trait Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct Defines a trait for serializing keys into unique strings, likely used for caching or identification purposes. ```APIDOC ## Trait: SerializableKey ### Description Provides a method to serialize a key into a unique string representation. ### Methods #### fn ser_key(&self) -> String Serializes the key to a unique string. ### Usage Example ```rust let my_key = "some_identifier"; let serialized = my_key.ser_key(); println!("Serialized key: {}", serialized); ``` ``` -------------------------------- ### Implement IntoRes for Patch Responses in Rust Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct This trait implementation facilitates the conversion of types into HTTP PATCH responses. It handles the serialization of output data into a response object, requiring a response type that can be tried, an encoding method, and thread-safety considerations. ```rust impl IntoRes, Response, E> for T where Response: TryRes, Encoding: Encodes, E: FromServerFnError + Send, T: Send, Source§ #### async fn into_res(self) -> Result ``` -------------------------------- ### Implement TryFrom for Type Conversion in Rust Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct This standard Rust trait allows for fallible conversions between types. It defines an associated `Error` type and a `try_from` method that returns a `Result`. ```rust impl TryFrom for T where U: Into, Source§ #### type Error = Infallible #### fn try_from(value: U) -> Result>::Error> ``` -------------------------------- ### Implement From Trait for IconProps in Rust Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct Shows the generic implementation of the `From` trait for type `T`. This allows for direct conversion of a type into itself, a common identity conversion in Rust. It signifies that the type can be trivially converted into itself. ```rust impl From for T Returns the argument unchanged. ``` -------------------------------- ### Implement Props Trait for IconProps in Rust Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct Implements the Props trait for the IconProps struct. This enables the struct to be used within the Leptos framework's component system, providing access to a builder and defining its role as a prop type. The associated type `Builder` is also defined here. ```rust impl Props for IconProps { type Builder = IconPropsBuilder fn builder() -> Self::Builder } ``` -------------------------------- ### Implement IntoRes for Put Responses in Rust Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct This trait provides functionality to serialize data into HTTP PUT responses. It depends on a `TryRes` compatible response type and an `Encodes` implementation for the data, with considerations for error handling and concurrency. ```rust impl IntoRes, Response, E> for T where Response: TryRes, Encoding: Encodes, E: FromServerFnError + Send, T: Send, Source§ #### async fn into_res(self) -> Result ``` -------------------------------- ### Implement TypeId Function for Any Trait in Rust Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct Demonstrates the implementation of the `type_id` function, part of the `Any` trait. This function returns the `TypeId` of the current type, which is useful for runtime type identification and dynamic dispatch. ```rust fn type_id(&self) -> TypeId Gets the `TypeId` of `self`. Read more ``` -------------------------------- ### Implement ErasedDestructor for Static Types in Rust Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct This trait implementation is for types that are `'static`, meaning they do not contain any non-static references. It's often used in scenarios requiring type erasure. ```rust impl ErasedDestructor for T where T: 'static, ``` -------------------------------- ### ErasedDestructor Trait Source: https://docs.rs/leptos_icons/0.7.0/leptos_icons/struct A marker trait indicating that a type has an `ErasedDestructor`. This is often used in scenarios involving dynamic dispatch or trait objects. ```APIDOC ## Trait: ErasedDestructor ### Description Marker trait indicating that a type implements an erased destructor. This trait is typically used for types that need to be dynamically deallocated, often in the context of trait objects or C interop. ### Constraints - **T: 'static** - The type `T` must have a static lifetime, meaning it does not contain any non-static references. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.