### Generic Blanket Implementations Source: https://docs.rs/glyphon/latest/glyphon/enum.PrepareError Documentation for blanket implementations that apply to generic types, including examples for Any and Borrow traits. ```APIDOC Generic Blanket Implementations: impl Any for T where T: 'static + ?Sized fn type_id(&self) -> TypeId - Gets the `TypeId` of `self`. impl Borrow for T where T: ?Sized fn borrow(&self) -> &T - Immutably borrows from an owned value. ``` -------------------------------- ### Create TextRenderer Source: https://docs.rs/glyphon/latest/glyphon/struct.TextRenderer Constructs a new TextRenderer instance. This requires an initialized TextAtlas, a wgpu Device, and optional multisample and depth-stencil states for rendering configuration. ```APIDOC pub fn new(atlas: &mut TextAtlas, device: &Device, multisample: MultisampleState, depth_stencil: Option) -> Self Creates a new TextRenderer. Parameters: - atlas: A mutable reference to the TextAtlas used for glyph caching. - device: A reference to the wgpu Device for creating rendering resources. - multisample: The multisample state for anti-aliasing. - depth_stencil: An optional depth-stencil state for depth testing. ``` -------------------------------- ### Glyphon Viewport API Source: https://docs.rs/glyphon/latest/glyphon/struct.Viewport API documentation for the Viewport struct in the glyphon crate. It covers the constructor 'new' which initializes a Viewport with a wgpu Device and a Cache. The Viewport controls the visible area for text rendering and clipping. ```APIDOC Viewport: __new__(device: &wgpu::Device, cache: &Cache) -> Self Creates a new `Viewport` with the given `device` and `cache`. - device: A reference to the wgpu Device. - cache: A reference to the Cache. - Returns: A new Viewport instance. ``` -------------------------------- ### Rust: Get TypeId from Any trait Source: https://docs.rs/glyphon/latest/glyphon/struct.Resolution Implements the `Any` trait for generic types `T` where `T` is `'static` and `Sized`. The `type_id` method returns the unique `TypeId` of the type. This is crucial for runtime type identification. ```rust impl Any for T where T: 'static + ?Sized, { fn type_id(&self) -> TypeId } ``` -------------------------------- ### Rust Into Trait Source: https://docs.rs/glyphon/latest/glyphon/enum.PrepareError The `Into` trait is used to perform conversions. It is the reciprocal of `From`, meaning if you have `From` for `U`, you can automatically get `Into` for `T`. The `into()` method calls the corresponding `U::from(self)` implementation. ```APIDOC trait Into { fn into(self) -> U; } // Example usage: // let s = String::from("hello"); // let owned_string: String = s.into(); // Calls String::from(s) ``` -------------------------------- ### TextRenderer Methods Overview Source: https://docs.rs/glyphon/latest/glyphon/struct.TextRenderer Lists the available methods for the TextRenderer struct. These methods are primarily used for preparing glyphs and rendering text. Specific signatures and detailed parameter descriptions are not provided in this overview. ```APIDOC TextRenderer Methods: - new() - prepare(text: &str, ...) - prepare_with_custom(text: &str, custom_data: ..., ...) - prepare_with_depth(text: &str, depth: f32, ...) - prepare_with_depth_and_custom(text: &str, depth: f32, custom_data: ..., ...) - render(renderer: &mut RenderPass, ...) Note: Full method signatures, parameter types, return values, and usage examples are not detailed in the provided text. ``` -------------------------------- ### Prepare Text Areas for Rendering Source: https://docs.rs/glyphon/latest/glyphon/struct.TextRenderer Prepares all provided text areas for rendering. This involves processing glyphs, updating the text atlas, and generating necessary render data. It requires mutable access to the device, queue, font system, atlas, viewport, and a cache. Returns a Result indicating success or a PrepareError. ```APIDOC pub fn prepare<'a>( &mut self, device: &Device, queue: &Queue, font_system: &mut FontSystem, atlas: &mut TextAtlas, viewport: &Viewport, text_areas: impl IntoIterator>, cache: &mut SwashCache, ) -> Result<(), PrepareError> Prepares all of the provided text areas for rendering. Parameters: - device: The wgpu Device. - queue: The wgpu Queue for command submission. - font_system: A mutable reference to the FontSystem for font loading and management. - atlas: A mutable reference to the TextAtlas for glyph caching. - viewport: The current viewport dimensions. - text_areas: An iterator over TextArea objects to prepare. - cache: A mutable reference to the SwashCache for glyph rasterization. Returns: - Ok(()): If preparation is successful. - Err(PrepareError): If an error occurs during preparation. ``` ```APIDOC pub fn prepare_with_depth<'a>( &mut self, device: &Device, queue: &Queue, font_system: &mut FontSystem, atlas: &mut TextAtlas, viewport: &Viewport, text_areas: impl IntoIterator>, cache: &mut SwashCache, metadata_to_depth: impl FnMut(usize) -> f32, ) -> Result<(), PrepareError> Prepares all of the provided text areas for rendering, allowing custom depth assignment. Parameters: - device: The wgpu Device. - queue: The wgpu Queue for command submission. - font_system: A mutable reference to the FontSystem. - atlas: A mutable reference to the TextAtlas. - viewport: The current viewport dimensions. - text_areas: An iterator over TextArea objects. - cache: A mutable reference to the SwashCache. - metadata_to_depth: A closure that maps metadata (e.g., text area index) to a depth value (f32). Returns: - Ok(()): If preparation is successful. - Err(PrepareError): If an error occurs during preparation. ``` -------------------------------- ### glyphon Cache API Source: https://docs.rs/glyphon/latest/glyphon/struct.Cache API documentation for the `glyphon::Cache` struct, detailing its constructor and purpose. It facilitates sharing common rendering resources. ```APIDOC glyphon::Cache Description: A cache to share common resources (e.g., pipelines, layouts, shaders) between multiple text renderers. Methods: new(device: &[Device]) -> Self Description: Creates a new `Cache` with the given `device`. Parameters: device: A reference to a wgpu Device. Returns: A new Cache instance. ``` -------------------------------- ### wgpu-types Send/Sync Traits for WebAssembly Source: https://docs.rs/glyphon/latest/glyphon/enum.ColorMode Documentation for traits related to thread safety (Send and Sync) and their specific handling within the WebAssembly context as defined in the wgpu-types crate. These traits are used to manage type compatibility and safety across different execution environments. ```APIDOC trait WasmNotSend for T where T: Send // Marks types that are Send but should not be sent across WASM threads. trait WasmNotSendSync for T where T: WasmNotSend + WasmNotSync // Marks types that are Send and Sync but should not be used across WASM threads. trait WasmNotSync for T where T: Sync // Marks types that are Sync but should not be synchronized across WASM threads. ``` -------------------------------- ### Prepare Text Areas with Depth and Custom Glyphs (Rust) Source: https://docs.rs/glyphon/latest/glyphon/struct.TextRenderer Prepares text areas for rendering with depth support and custom glyph rasterization. Similar to `prepare_with_custom`, but also accepts a `metadata_to_depth` closure to determine depth. Returns a `Result` indicating success or a `PrepareError`. ```rust pub fn prepare_with_depth_and_custom<'a>( &mut self, device: &[Device], queue: &[Queue], font_system: &mut FontSystem, atlas: &mut TextAtlas, viewport: &[Viewport], text_areas: impl IntoIterator>, cache: &mut SwashCache, metadata_to_depth: impl FnMut(usize) -> f32, rasterize_custom_glyph: impl FnMut(RasterizeCustomGlyphRequest) -> Option, ) -> Result<(), PrepareError> ``` -------------------------------- ### wgpu-types Send/Sync Traits for WebAssembly Source: https://docs.rs/glyphon/latest/glyphon/enum.ContentType Documentation for traits related to thread safety (Send and Sync) and their specific handling within the WebAssembly context as defined in the wgpu-types crate. These traits are used to manage type compatibility and safety across different execution environments. ```APIDOC trait WasmNotSend for T where T: Send // Marks types that are Send but should not be sent across WASM threads. trait WasmNotSendSync for T where T: WasmNotSend + WasmNotSync // Marks types that are Send and Sync but should not be used across WASM threads. trait WasmNotSync for T where T: Sync // Marks types that are Sync but should not be synchronized across WASM threads. ``` -------------------------------- ### Prepare Text Areas with Custom Glyphs (Rust) Source: https://docs.rs/glyphon/latest/glyphon/struct.TextRenderer Prepares text areas for rendering, supporting custom glyph rasterization. It takes mutable references to `FontSystem`, `TextAtlas`, `SwashCache`, and iterators of `TextArea`, along with a custom rasterization closure. Returns a `Result` indicating success or a `PrepareError`. ```rust pub fn prepare_with_custom<'a>( &mut self, device: &[Device], queue: &[Queue], font_system: &mut FontSystem, atlas: &mut TextAtlas, viewport: &[Viewport], text_areas: impl IntoIterator>, cache: &mut SwashCache, rasterize_custom_glyph: impl FnMut(RasterizeCustomGlyphRequest) -> Option, ) -> Result<(), PrepareError> ``` -------------------------------- ### TextBounds Struct API Documentation Source: https://docs.rs/glyphon/latest/glyphon/struct.TextBounds Provides detailed API documentation for the TextBounds struct, including its fields and implemented methods from various traits. This covers the structure's purpose in defining visible text areas and its behavior through standard Rust trait implementations. ```APIDOC TextBounds: Fields: left: i32 The position of the left edge of the visible area. top: i32 The position of the top edge of the visible area. right: i32 The position of the right edge of the visible area. bottom: i32 The position of the bottom edge of the visible area. Trait Implementations: Clone: clone(&self) -> TextBounds Returns a duplicate of the value. clone_from(&mut self, source: &Self) Performs copy-assignment from `source`. Debug: fmt(&self, f: &mut Formatter) -> Result Formats the value using the given formatter. Default: default() -> Self The default visible area doesn’t clip any text. Returns the “default value” for a type. PartialEq: eq(&self, other: &TextBounds) -> bool Tests for `self` and `other` values to be equal, and is used by `==`. ne(&self, other: &TextBounds) -> bool Tests for `!=`. Copy: (Implicitly implemented as all fields are Copy) Eq: (Implemented as PartialEq is implemented and all fields are Eq) StructuralPartialEq: (Implemented as PartialEq is implemented and all fields are StructuralPartialEq) ``` -------------------------------- ### TextAtlas Structure and Methods Source: https://docs.rs/glyphon/latest/glyphon/struct.TextAtlas API documentation for the TextAtlas struct in the glyphon crate. Covers its definition, creation via `new`, and other methods like `trim` and `with_color_mode`. Details include parameters for `new` and its return type. ```APIDOC Struct TextAtlas Description: An atlas containing a cache of rasterized glyphs that can be rendered. Fields: /* private fields */ Methods: new(device: &Device, queue: &Queue, cache: &Cache, format: TextureFormat) -> Self Description: Creates a new TextAtlas. Parameters: device: A reference to the wgpu Device. queue: A reference to the wgpu Queue. cache: A reference to the Cache struct. format: The TextureFormat for the atlas. Returns: A new TextAtlas instance. Source: ../src/glyphon/text_atlas.rs trim() Description: Trims unused space from the atlas. (Details not fully provided in text) with_color_mode() Description: Creates a new TextAtlas with a specified color mode. (Details not fully provided in text) ``` -------------------------------- ### ContentType Methods and Implementations Source: https://docs.rs/glyphon/latest/glyphon/enum.ContentType Lists the methods and trait implementations available for the ContentType enum in the glyphon crate. This includes the bytes_per_pixel method and standard trait implementations like Clone, Copy, Debug, Eq, PartialEq, and more. ```APIDOC Enum: ContentType Methods: - bytes_per_pixel: Returns the number of bytes per pixel for the content type. Trait Implementations: - Clone: Allows creating a copy of the ContentType value. - Copy: Indicates that ContentType can be copied by value. - Debug: Enables formatting for debugging purposes. - Eq: Allows for equality comparison. - PartialEq: Enables comparison for equality. - StructuralPartialEq: Enables structural equality comparison. Auto Trait Implementations: - Freeze, RefUnwindSafe, Send, Sync, Unpin, UnwindSafe: Standard Rust safety and concurrency traits. Blanket Implementations: - Any, Borrow, BorrowMut, CloneToUninit, Equivalent, From, Into, ToOwned, TryFrom, TryInto, WasmNotSend, WasmNotSendSync, WasmNotSync: Generic implementations provided by Rust's standard library and other crates. ``` -------------------------------- ### Rust TryFrom and TryInto Traits Source: https://docs.rs/glyphon/latest/glyphon/enum.ContentType Documentation for the Rust standard library's TryFrom and TryInto traits, which provide a mechanism for fallible type conversions. This includes their associated error types and the core conversion methods. ```APIDOC trait TryFrom { type Error; fn try_from(value: U) -> Result; } // Associated type for error: // type Error = Infallible; // The type returned in the event of a conversion error. // Method signature: // fn try_from(value: U) -> Result>::Error> // Performs the conversion. trait TryInto { type Error; fn try_into(self) -> Result; } // Implementation block: // impl TryInto for T where U: TryFrom // Associated type for error: // type Error = >::Error; // The type returned in the event of a conversion error. // Method signature: // fn try_into(self) -> Result>::Error> // Performs the conversion. ``` -------------------------------- ### Rust TryFrom and TryInto Traits Source: https://docs.rs/glyphon/latest/glyphon/enum.ColorMode Documentation for the Rust standard library's TryFrom and TryInto traits, which provide a mechanism for fallible type conversions. This includes their associated error types and the core conversion methods. ```APIDOC trait TryFrom { type Error; fn try_from(value: U) -> Result; } // Associated type for error: // type Error = Infallible; // The type returned in the event of a conversion error. // Method signature: // fn try_from(value: U) -> Result>::Error> // Performs the conversion. trait TryInto { type Error; fn try_into(self) -> Result; } // Implementation block: // impl TryInto for T where U: TryFrom // Associated type for error: // type Error = >::Error; // The type returned in the event of a conversion error. // Method signature: // fn try_into(self) -> Result>::Error> // Performs the conversion. ``` -------------------------------- ### Render Text Layouts (Rust) Source: https://docs.rs/glyphon/latest/glyphon/struct.TextRenderer Renders all layouts that were previously prepared by `prepare` methods. It requires the `TextAtlas`, `Viewport`, and a mutable `RenderPass` reference. Returns a `Result` indicating success or a `RenderError`. ```rust pub fn render( &self, atlas: &[TextAtlas], viewport: &[Viewport], pass: &mut RenderPass<'_>, ) -> Result<(), RenderError> ``` -------------------------------- ### TextArea Blanket Implementations Source: https://docs.rs/glyphon/latest/glyphon/struct.TextArea Details blanket implementations for TextArea, such as the Any trait for runtime type identification and the Borrow trait for shared access. ```APIDOC TextArea Blanket Implementations: Any: type_id(&self) -> TypeId Gets the `TypeId` of `self`. Borrow: borrow(&self) -> &T Implements shared access to the struct's data. ``` -------------------------------- ### Rust: CloneToUninit Trait Source: https://docs.rs/glyphon/latest/glyphon/struct.RasterizeCustomGlyphRequest Documentation for the nightly-only experimental CloneToUninit trait. It provides a method for copy-assigning data to an uninitialized destination. ```APIDOC trait CloneToUninit unsafe fn clone_to_uninit(&self, dest: *mut T) - Description: Performs copy-assignment from `self` to `dest`. - Note: This is a nightly-only experimental API. - Parameters: - self: The source data to clone. - dest: A mutable pointer to the uninitialized destination buffer. - Returns: None (modifies `dest` in place). - Source: https://doc.rust-lang.org/nightly/core/clone/trait.CloneToUninit.html#tymethod.clone_to_uninit ``` -------------------------------- ### Rust WasmSendSync Traits Source: https://docs.rs/glyphon/latest/glyphon/struct.Resolution Documentation for send and sync traits specific to WebAssembly contexts, as found in the wgpu-types crate. These traits help manage thread safety and data transfer limitations within WASM environments. ```APIDOC Rust WasmSendSync Traits (wgpu-types) // Trait indicating a type is not Send across WASM threads. trait WasmNotSend for T where T: Send; // Trait indicating a type is not Sync across WASM threads. trait WasmNotSync for T where T: Sync; // Trait combining WasmNotSend and WasmNotSync. trait WasmNotSendSync for T where T: WasmNotSend + WasmNotSync; // Example implementations: // impl WasmNotSend for T where T: Send {} // impl WasmNotSync for T where T: Sync {} // impl WasmNotSendSync for T where T: WasmNotSend + WasmNotSync {} ``` -------------------------------- ### Rust TryFrom and TryInto Traits Source: https://docs.rs/glyphon/latest/glyphon/struct.TextArea Documentation for the TryFrom and TryInto traits in Rust's standard library, which provide fallible conversion mechanisms. TryFrom allows conversion from a source type U to a target type T, returning a Result. TryInto is the reciprocal trait, often implemented automatically when TryFrom is available. ```APIDOC trait TryFrom for T where U: Into associatedtype Error = Infallible fn try_from(value: U) -> Result Performs the conversion. trait TryInto for T where U: TryFrom associatedtype Error = >::Error fn try_into(self) -> Result Performs the conversion. ``` -------------------------------- ### Create TextAtlas with ColorMode - Rust Source: https://docs.rs/glyphon/latest/glyphon/struct.TextAtlas Creates a new TextAtlas instance with the specified ColorMode. This function requires a wgpu device, queue, glyphon cache, and texture format as dependencies. It returns the newly created TextAtlas. ```rust pub fn with_color_mode( device: &[Device], queue: &[Queue], cache: &[Cache], format: TextureFormat, color_mode: ColorMode, ) -> Self ``` -------------------------------- ### Glyphon Viewport Methods: update and resolution Source: https://docs.rs/glyphon/latest/glyphon/struct.Viewport Provides documentation for the `update` and `resolution` methods of the Glyphon Viewport struct. The `update` method modifies the viewport's resolution, while `resolution` retrieves the current resolution. ```rust pub fn update(&mut self, queue: &[Queue], resolution: Resolution) Updates the `Viewport` with the given `resolution`. Source: ../src/glyphon/viewport.rs.html#60-62 ``` ```rust pub fn resolution(&self) -> Resolution Returns the current resolution of the `Viewport`. Source: ../src/glyphon/viewport.rs.html#11 ``` -------------------------------- ### Glyphon Structs Source: https://docs.rs/glyphon/latest/glyphon/index Definitions and descriptions of core structs in the glyphon library for text rendering. ```rust struct Cache; // A cache to share common resources (e.g., pipelines, layouts, shaders) between multiple text renderers. ``` ```rust struct CustomGlyph; // A custom glyph to render ``` ```rust struct RasterizeCustomGlyphRequest; // A request to rasterize a custom glyph ``` ```rust struct RasterizedCustomGlyph; // A rasterized custom glyph ``` ```rust struct Resolution; // The screen resolution to use when rendering text. ``` ```rust struct TextArea; // A text area containing text to be rendered along with its overflow behavior. ``` ```rust struct TextAtlas; // An atlas containing a cache of rasterized glyphs that can be rendered. ``` ```rust struct TextBounds; // Controls the visible area of the text. Any text outside of the visible area will be clipped. ``` ```rust struct TextRenderer; // A text renderer that uses cached glyphs to render text into an existing render pass. ``` ```rust struct Viewport; // Controls the visible area of all text for a given renderer. Any text outside of the visible area will be clipped. ``` -------------------------------- ### Rust From and Into Trait Conversions Source: https://docs.rs/glyphon/latest/glyphon/struct.Cache Documentation for the From and Into traits, which facilitate type conversions in Rust. The From trait provides a way to convert one type into another, while Into provides the reciprocal conversion. ```APIDOC 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)`. - This conversion is whatever the implementation of `From for U` chooses to do. ``` -------------------------------- ### Rust From Trait Source: https://docs.rs/glyphon/latest/glyphon/struct.Resolution Documentation for the `From` trait and its `from` method. This trait provides a standard way to perform conversions into a type, often used for creating new instances from existing ones. ```rust impl From for T fn from(t: T) -> T Returns the argument unchanged. ``` -------------------------------- ### Rust TryFrom and TryInto Traits Source: https://docs.rs/glyphon/latest/glyphon/struct.RasterizedCustomGlyph Documentation for the TryFrom and TryInto traits in Rust's standard library, which provide fallible conversion mechanisms. TryFrom allows conversion from a source type U to a target type T, returning a Result. TryInto is the reciprocal trait, often implemented automatically when TryFrom is available. ```APIDOC trait TryFrom for T where U: Into associatedtype Error = Infallible fn try_from(value: U) -> Result Performs the conversion. trait TryInto for T where U: TryFrom associatedtype Error = >::Error fn try_into(self) -> Result Performs the conversion. ``` -------------------------------- ### Rust WasmSendSync Traits Source: https://docs.rs/glyphon/latest/glyphon/struct.Cache Documentation for send and sync traits specific to WebAssembly contexts, as found in the wgpu-types crate. These traits help manage thread safety and data transfer limitations within WASM environments. ```APIDOC Rust WasmSendSync Traits (wgpu-types) // Trait indicating a type is not Send across WASM threads. trait WasmNotSend for T where T: Send; // Trait indicating a type is not Sync across WASM threads. trait WasmNotSync for T where T: Sync; // Trait combining WasmNotSend and WasmNotSync. trait WasmNotSendSync for T where T: WasmNotSend + WasmNotSync; // Example implementations: // impl WasmNotSend for T where T: Send {} // impl WasmNotSync for T where T: Sync {} // impl WasmNotSendSync for T where T: WasmNotSend + WasmNotSync {} ``` -------------------------------- ### Rust CloneToUninit Trait Source: https://docs.rs/glyphon/latest/glyphon/struct.RasterizedCustomGlyph The `CloneToUninit` trait, an experimental nightly-only API, allows for copy-assignment from an owned value to an uninitialized memory location. ```APIDOC trait CloneToUninit for T where T: Clone unsafe fn clone_to_uninit(&self, dest: *mut u8) Performs copy-assignment from `self` to `dest`. This is a nightly-only experimental API. Parameters: - self: The value to clone. - dest: A mutable pointer to the destination memory. ``` -------------------------------- ### Generic Blanket Implementations Source: https://docs.rs/glyphon/latest/glyphon/enum.RenderError Showcases blanket implementations for generic types 'T', demonstrating common trait functionalities available for most types in Rust. This includes Any and Borrow. ```APIDOC impl Any for T where T: 'static + ?Sized - Provides access to type information at runtime. fn type_id(&self) -> TypeId - Gets the TypeId of `self`. impl Borrow for T where T: ?Sized - Implements immutable borrowing for any type. fn borrow(&self) -> &T - Immutably borrows from an owned value. ``` -------------------------------- ### Glyphon ContentType API Documentation Source: https://docs.rs/glyphon/latest/glyphon/enum.ContentType Provides details on the methods and trait implementations available for the ContentType enum in the glyphon crate. This includes the bytes_per_pixel method and implementations for standard traits like Clone, Debug, PartialEq, Copy, Eq, and others. ```APIDOC enum ContentType Method: bytes_per_pixel Signature: pub fn bytes_per_pixel(&self) -> usize Description: The number of bytes per pixel for this content type Source: ../src/glyphon/custom_glyph.rs.html#111-116 Trait: Clone Signature: impl Clone for ContentType Methods: - clone: fn clone(&self) -> ContentType Description: Returns a duplicate of the value. Source: ../src/glyphon/custom_glyph.rs.html#101 - clone_from: fn clone_from(&mut self, source: &Self) Description: Performs copy-assignment from `source`. Source: ../src/glyphon/custom_glyph.rs.html#101 Trait: Debug Signature: impl Debug for ContentType Methods: - fmt: fn fmt(&self, f: &mut Formatter<'_>) -> Result Description: Formats the value using the given formatter. Source: ../src/glyphon/custom_glyph.rs.html#101 Trait: PartialEq Signature: impl PartialEq for ContentType Methods: - eq: fn eq(&self, other: &ContentType) -> bool Description: Tests for `self` and `other` values to be equal, and is used by `==`. Source: ../src/glyphon/custom_glyph.rs.html#101 - ne: fn ne(&self, other: &Self) -> bool Description: Tests for `!=`. Source: ../src/glyphon/custom_glyph.rs.html#101 Trait: Copy Signature: impl Copy for ContentType Source: ../src/glyphon/custom_glyph.rs.html#101 Trait: Eq Signature: impl Eq for ContentType Source: ../src/glyphon/custom_glyph.rs.html#101 Trait: StructuralPartialEq Signature: impl StructuralPartialEq for ContentType Source: ../src/glyphon/custom_glyph.rs.html#101 Auto Trait Implementations: - Freeze - RefUnwindSafe - Send - Sync ``` -------------------------------- ### Rust: Equivalent Trait Methods Source: https://docs.rs/glyphon/latest/glyphon/struct.TextBounds Documentation for the `Equivalent` trait, which allows checking for equality between different types, often used in hashing and collections. It includes the `equivalent` method signature and its purpose. ```APIDOC Equivalent for Q where Q: Eq + ?Sized, K: Borrow + ?Sized fn equivalent(&self, key: &K) -> bool - Checks if this value is equivalent to the given key. - Parameters: - key: A reference to the key to compare against. - Returns: A boolean indicating whether the values are equivalent. ``` -------------------------------- ### Rust: TryFrom and TryInto Traits Source: https://docs.rs/glyphon/latest/glyphon/struct.RasterizeCustomGlyphRequest Documentation for the TryFrom and TryInto traits, which provide fallible type conversions. TryFrom attempts a conversion and returns a Result, while TryInto is its reciprocal. ```APIDOC trait TryFrom type Error - Description: The type returned in the event of a conversion error. fn try_from(value: U) -> Result - Description: Performs the conversion. Returns `Ok(T)` on success or `Err(E)` on failure. - Parameters: - value: The value to convert. - Returns: A `Result` containing the converted value or an error. - Source: https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from trait TryInto type Error - Description: The type returned in the event of a conversion error. - Note: This trait is the reciprocal of `TryFrom`. - Source: https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error ``` -------------------------------- ### Rust CloneToUninit Trait Source: https://docs.rs/glyphon/latest/glyphon/struct.TextArea The `CloneToUninit` trait, an experimental nightly-only API, allows for copy-assignment from an owned value to an uninitialized memory location. ```APIDOC trait CloneToUninit for T where T: Clone unsafe fn clone_to_uninit(&self, dest: *mut u8) Performs copy-assignment from `self` to `dest`. This is a nightly-only experimental API. Parameters: - self: The value to clone. - dest: A mutable pointer to the destination memory. ``` -------------------------------- ### Rust: PrepareError Debug and Display Methods Source: https://docs.rs/glyphon/latest/glyphon/enum.PrepareError Details the `fmt` method implementations for the `Debug` and `Display` traits for the PrepareError enum. These methods are used for formatting the error for debugging output and user-facing messages, respectively. ```APIDOC impl Debug for PrepareError fn fmt(&self, f: &mut Formatter<'_>) -> Result - Formats the value using the given formatter. impl Display for PrepareError fn fmt(&self, f: &mut Formatter<'_>) -> Result - Formats the value using the given formatter. ``` -------------------------------- ### Rust TryInto Trait Implementation Source: https://docs.rs/glyphon/latest/glyphon/enum.PrepareError Documentation for the TryInto trait, which provides a fallible conversion from one type to another. It defines an associated Error type and the try_into method for performing the conversion. ```APIDOC impl TryInto for T where U: TryFrom associatedtype Error = >::Error fn try_into(self) -> Result>::Error> Performs the conversion. ``` -------------------------------- ### Rust: Into and From Trait Conversion Source: https://docs.rs/glyphon/latest/glyphon/struct.TextRenderer Documents the `Into` and `From` traits in Rust, which facilitate automatic type conversions. `Into::into` calls `From::from`, enabling conversions when a `From for U` implementation exists. This is a fundamental pattern for ergonomic type handling in Rust. ```rust /// Calls `U::from(self)`. /// That is, this conversion is whatever the implementation of /// `From for U` chooses to do. fn into(self) -> U ``` -------------------------------- ### Rust: PrepareError Error Handling Methods Source: https://docs.rs/glyphon/latest/glyphon/enum.PrepareError Documents the methods implemented for the standard Rust `Error` trait for the PrepareError enum. This includes methods for accessing the underlying error source, deprecated methods for description and cause, and the experimental `provide` method for error reporting context. ```APIDOC impl Error for PrepareError fn source(&self) -> Option<&(dyn Error + 'static)> - Returns the lower-level source of this error, if any. fn description(&self) -> &str - Deprecated since 1.42.0: use the Display impl or to_string(). Returns a string description of the error. fn cause(&self) -> Option<&(dyn Error)> - Deprecated since 1.33.0: replaced by Error::source. Returns the underlying cause of the error. fn provide<'a>(&'a self, request: &mut Request<'a>) - Experimental API: Provides type-based access to context intended for error reports. ``` -------------------------------- ### Rust Traits: TryFrom and TryInto Source: https://docs.rs/glyphon/latest/glyphon/struct.Resolution Documentation for the standard Rust traits TryFrom and TryInto, which provide a mechanism for fallible type conversions. TryFrom allows converting from a source type U to a target type T, returning a Result. TryInto is the reciprocal trait, often implemented automatically when TryFrom is available. ```APIDOC Rust Traits: TryFrom and TryInto // Trait for fallible conversions trait TryFrom: Sized { type Error; // The type returned in the event of a conversion error. // Performs the conversion. fn try_from(value: U) -> Result; } // Trait for fallible conversions (reverse of TryFrom) trait TryInto: Sized { type Error; // The type returned in the event of a conversion error. // Performs the conversion. fn try_into(self) -> Result; } // Note: TryInto for T is automatically implemented if U: TryFrom. ``` -------------------------------- ### Rust: From and Into Trait Conversions Source: https://docs.rs/glyphon/latest/glyphon/struct.TextBounds Documentation for the `From` and `Into` traits, which facilitate type conversions in Rust. `From` is the primary conversion trait, while `Into` is a convenience wrapper that calls `From::from`. ```APIDOC From for T fn from(t: T) -> T - Returns the argument unchanged. - Parameters: - t: The value to convert. - Returns: The value itself. ``` ```APIDOC Into for T where U: From fn into(self) -> U - Calls `U::from(self)`. - This conversion is whatever the implementation of `From for U` chooses to do. - Parameters: - self: The value to convert. - Returns: The converted value of type U. ``` -------------------------------- ### Rust Traits: TryFrom and TryInto Source: https://docs.rs/glyphon/latest/glyphon/struct.Cache Documentation for the standard Rust traits TryFrom and TryInto, which provide a mechanism for fallible type conversions. TryFrom allows converting from a source type U to a target type T, returning a Result. TryInto is the reciprocal trait, often implemented automatically when TryFrom is available. ```APIDOC Rust Traits: TryFrom and TryInto // Trait for fallible conversions trait TryFrom: Sized { type Error; // The type returned in the event of a conversion error. // Performs the conversion. fn try_from(value: U) -> Result; } // Trait for fallible conversions (reverse of TryFrom) trait TryInto: Sized { type Error; // The type returned in the event of a conversion error. // Performs the conversion. fn try_into(self) -> Result; } // Note: TryInto for T is automatically implemented if U: TryFrom. ``` -------------------------------- ### RasterizedCustomGlyph API Documentation (Rust) Source: https://docs.rs/glyphon/latest/glyphon/struct.RasterizedCustomGlyph Provides detailed API documentation for the RasterizedCustomGlyph struct, including its fields, their types and descriptions, and implemented traits. ```APIDOC Struct: RasterizedCustomGlyph Description: A rasterized custom glyph. Fields: data: Vec Description: The raw image data. Type: Vec content_type: ContentType Description: The type of image data contained in `data`. Type: ContentType Trait Implementations: Clone: Implements the Clone trait for deep copying. Debug: Implements the Debug trait for formatted output. Auto Trait Implementations: Freeze: Indicates the type is safe to freeze. RefUnwindSafe: Indicates the type is safe for unwinding references. Send: Indicates the type can be safely sent between threads. Sync: Indicates the type can be safely shared between threads. Unpin: Indicates the type does not require special handling for pinning. UnwindSafe: Indicates the type is safe during unwinding. Blanket Implementations: Any: Implements the Any trait for dynamic typing. Borrow: Implements the Borrow trait for shared references. BorrowMut: Implements the BorrowMut trait for mutable references. CloneToUninit: Implements cloning to uninitialized memory. From: Implements conversion from other types. Into: Implements conversion into other types. ToOwned: Implements conversion to an owned type. TryFrom: Implements fallible conversion from other types. TryInto: Implements fallible conversion into other types. WasmNotSend: Indicates the type is not Send in WebAssembly. WasmNotSendSync: Indicates the type is not Send or Sync in WebAssembly. WasmNotSync: Indicates the type is not Sync in WebAssembly. ``` -------------------------------- ### Rust: PrepareError Clone Methods Source: https://docs.rs/glyphon/latest/glyphon/enum.PrepareError Documents the `clone` and `clone_from` methods implemented for the PrepareError enum, allowing for the creation of duplicate error instances. These methods are part of the standard Rust `Clone` trait. ```APIDOC impl Clone for PrepareError fn clone(&self) -> PrepareError - Returns a duplicate of the value. fn clone_from(&mut self, source: &Self) - Performs copy-assignment from `source`. ``` -------------------------------- ### Rust CloneToUninit Trait clone_to_uninit Method Source: https://docs.rs/glyphon/latest/glyphon/struct.Cache The unsafe clone_to_uninit method from the CloneToUninit trait performs copy-assignment from self to a destination pointer. This is a nightly-only experimental API for low-level cloning operations. ```Rust unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### Rust: hashbrown::Equivalent::equivalent Method Source: https://docs.rs/glyphon/latest/glyphon/enum.PrepareError This method checks if a value is equivalent to a given key, typically used in hash map implementations. It requires the type `Q` to implement `Eq` and `K` to implement `Borrow`. This specific implementation is from the `hashbrown` crate. ```rust fn equivalent(&self, key: &K) -> bool where Q: Eq + ?Sized, K: Borrow + ?Sized, ``` -------------------------------- ### Rust TryInto Trait Implementation Source: https://docs.rs/glyphon/latest/glyphon/enum.RenderError Documentation for the TryInto trait, which provides a fallible conversion from one type to another. It defines an associated Error type and the try_into method for performing the conversion. ```APIDOC impl TryInto for T where U: TryFrom associatedtype Error = >::Error fn try_into(self) -> Result>::Error> Performs the conversion. ``` -------------------------------- ### Glyphon Viewport Debug Implementation Source: https://docs.rs/glyphon/latest/glyphon/struct.Viewport Details the implementation of the `Debug` trait for the Glyphon Viewport struct. This allows the Viewport to be formatted for debugging purposes. ```rust impl Debug for Viewport Source: ../src/glyphon/viewport.rs.html#11 fn fmt(&self, f: &mut Formatter<'_>) -> Result Formats the value using the given formatter. [Read more](https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt) Source: ../src/glyphon/viewport.rs.html#11 ``` -------------------------------- ### TextBounds Trait Implementations Source: https://docs.rs/glyphon/latest/glyphon/struct.TextBounds Details the core trait implementations for the TextBounds struct, enabling common operations like copying, debugging, and comparison. It also lists auto-trait implementations for thread safety and blanket implementations for generic functionality. ```APIDOC Struct: TextBounds Fields: - bottom: i32 - left: i32 - right: i32 - top: i32 Trait Implementations: - Clone: Allows creating a copy of the TextBounds instance. - Copy: Indicates that TextBounds can be copied by bitwise operations. - Debug: Enables formatting for debugging purposes. - Default: Provides a default value for TextBounds (likely zeroed). - Eq: Enables equality comparison between TextBounds instances. - PartialEq: Enables partial equality comparison. - StructuralPartialEq: Enables structural equality comparison. Auto Trait Implementations: - Freeze: Indicates thread safety for immutable access. - RefUnwindSafe: Guarantees safety when unwinding across references. - Send: Indicates that the type can be safely sent between threads. - Sync: Indicates that the type can be safely shared between threads. - Unpin: Guarantees that the type's memory location is stable. - UnwindSafe: Guarantees safety when unwinding. Blanket Implementations (for T): - Any: Allows downcasting to concrete types. - Borrow: Enables borrowing the struct as a reference. - BorrowMut: Enables mutable borrowing. - CloneToUninit: Allows cloning into uninitialized memory. - Equivalent: For key equivalence checks. - From: For creating TextBounds from compatible types. - Into: For converting TextBounds into other types. - ToOwned: For creating an owned version. - TryFrom: For fallible conversion from other types. - TryInto: For fallible conversion into other types. - WasmNotSend: Indicates not safe to send across WebAssembly boundaries. - WasmNotSendSync: Indicates not safe to share across WebAssembly boundaries. - WasmNotSync: Indicates not safe to share immutably across WebAssembly boundaries. ```