### Example: Trim ASCII Start Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Demonstrates trimming leading ASCII whitespace from a byte slice using `trim_ascii_start`. ```rust assert_eq!(b" \t hello world\n".trim_ascii_start(), b"hello world\n"); assert_eq!(b" ".trim_ascii_start(), b""); assert_eq!(b"" .trim_ascii_start(), b""); ``` -------------------------------- ### Example: First Element of Slice Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Demonstrates getting the first element of a slice using the `first` method, which returns an Option. ```rust let v = [10, 40, 30]; assert_eq!(Some(&10), v.first()); let w: &[i32] = &[]; assert_eq!(None, w.first()); ``` -------------------------------- ### Example: Slice Length Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Demonstrates getting the length of a slice using the `len` method. ```rust let a = [1, 2, 3]; assert_eq!(a.len(), 3); ``` -------------------------------- ### Example: Split First Element Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Demonstrates splitting a slice into its first element and the rest of the slice using `split_first`. ```rust let x = &[0, 1, 2]; if let Some((first, elements)) = x.split_first() { assert_eq!(first, &0); assert_eq!(elements, &[1, 2]); } ``` -------------------------------- ### Trim Prefix Example Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Shows how to remove a prefix from a slice. This is a nightly-only experimental API. ```rust #![feature(trim_prefix_suffix)] let v = &[10, 40, 30]; // Prefix present - removes it assert_eq!(v.trim_prefix(&[10]), &[40, 30][..]); assert_eq!(v.trim_prefix(&[10, 40]), &[30][..]); assert_eq!(v.trim_prefix(&[10, 40, 30]), &[][..]); // Prefix absent - returns original slice assert_eq!(v.trim_prefix(&[50]), &[10, 40, 30][..]); assert_eq!(v.trim_prefix(&[10, 50]), &[10, 40, 30][..]); let prefix : &str = "he"; assert_eq!(b"hello".trim_prefix(prefix.as_bytes()), b"llo".as_ref()); ``` -------------------------------- ### impl GetSize for WgpuOutputView<'_> Source: https://docs.rs/librashader/latest/librashader/runtime/wgpu/struct.WgpuOutputView.html Provides functionality to get the size of the WgpuOutputView. ```APIDOC ## type Error = Infallible ## fn size(&self) -> Result, as GetSize>::Error> Fetch the size of the object ``` -------------------------------- ### Binary Search Example Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Demonstrates binary search on a sorted slice. The result is `Ok(index)` if found, or `Err(insertion_point)` if not found. ```rust let s = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]; assert_eq!(s.binary_search(&13), Ok(9)); assert_eq!(s.binary_search(&4), Err(7)); assert_eq!(s.binary_search(&100), Err(13)); let r = s.binary_search(&1); assert!(match r { Ok(1..=4) => true, _ => false, }); ``` -------------------------------- ### starts_with Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Checks if the slice starts with the given prefix slice. ```APIDOC ## pub fn starts_with(&self, needle: &[T]) -> bool where T: PartialEq, ### Description Returns `true` if `needle` is a prefix of the slice or equal to the slice. ### Parameters - `needle`: The slice to check as a prefix. ### Returns - `true` if `needle` is a prefix of the slice, `false` otherwise. ### Examples ```rust let v = [10, 40, 30]; assert!(v.starts_with(&[10])); assert!(v.starts_with(&[10, 40])); assert!(v.starts_with(&v)); assert!(!v.starts_with(&[50])); assert!(!v.starts_with(&[10, 50])); ``` Always returns `true` if `needle` is an empty slice: ```rust let v = &[10, 40, 30]; assert!(v.starts_with(&[])); let v: &[u8] = &[]; assert!(v.starts_with(&[])); ``` ``` -------------------------------- ### Example: Escape ASCII Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Demonstrates how to use the `escape_ascii` method to escape non-printable ASCII characters in a byte slice. ```rust let s = b"0\t\r\n'\"\\\x9d"; let escaped = s.escape_ascii().to_string(); assert_eq!(escaped, "0\\t\\r\\n\'\\"\\\\\\x9d"); ``` -------------------------------- ### Example: Trim ASCII Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Demonstrates trimming both leading and trailing ASCII whitespace from a byte slice using `trim_ascii`. ```rust assert_eq!(b"\r hello world\n ".trim_ascii(), b"hello world"); assert_eq!(b" ".trim_ascii(), b""); assert_eq!(b"" .trim_ascii(), b""); ``` -------------------------------- ### Example: Slice is Empty Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Demonstrates checking if a slice is empty using the `is_empty` method. ```rust let a = [1, 2, 3]; assert!(!a.is_empty()); let b: &[i32] = &[]; assert!(b.is_empty()); ``` -------------------------------- ### Glslang Implementation for SpirvCompilation Source: https://docs.rs/librashader/latest/librashader/reflect/trait.ShaderInputCompiler.html Example of Glslang implementing ShaderInputCompiler to produce SpirvCompilation units. ```rust impl ShaderInputCompiler for Glslang ``` -------------------------------- ### Example: Split Last Element Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Demonstrates splitting a slice into its last element and the rest of the slice using `split_last`. ```rust let x = &[0, 1, 2]; if let Some((last, elements)) = x.split_last() { assert_eq!(last, &2); assert_eq!(elements, &[0, 1]); } ``` -------------------------------- ### Create a new WildcardContext Source: https://docs.rs/librashader/latest/librashader/presets/context/struct.WildcardContext.html Instantiates a new, empty WildcardContext. Use this as a starting point for building your shader context. ```rust pub fn new() -> WildcardContext ``` -------------------------------- ### Trim Suffix Example Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Illustrates removing a suffix from a slice. This is a nightly-only experimental API. ```rust #![feature(trim_prefix_suffix)] let v = &[10, 40, 30]; // Suffix present - removes it assert_eq!(v.trim_suffix(&[30]), &[10, 40][..]); assert_eq!(v.trim_suffix(&[40, 30]), &[10][..]); assert_eq!(v.trim_suffix(&[10, 40, 30]), &[][..]); // Suffix absent - returns original slice assert_eq!(v.trim_suffix(&[50]), &[10, 40, 30][..]); assert_eq!(v.trim_suffix(&[50, 30]), &[10, 40, 30][..]); ``` -------------------------------- ### TryFrom<(PhysicalDevice, Instance, Device, Queue)> for VulkanObjects Source: https://docs.rs/librashader/latest/librashader/runtime/vk/struct.VulkanObjects.html Allows creating a VulkanObjects instance from a PhysicalDevice, Instance, Device, and Queue. ```APIDOC ### impl TryFrom<(PhysicalDevice, Instance, Device, Queue)> for VulkanObjects ```rust fn try_from( value: (PhysicalDevice, Instance, Device, Queue), ) -> Result ``` Performs the conversion. ``` -------------------------------- ### TryFrom<(PhysicalDevice, Instance, Device)> for VulkanObjects Source: https://docs.rs/librashader/latest/librashader/runtime/vk/struct.VulkanObjects.html Allows creating a VulkanObjects instance from a PhysicalDevice, Instance, and Device. ```APIDOC ### impl TryFrom<(PhysicalDevice, Instance, Device)> for VulkanObjects ```rust fn try_from( value: (PhysicalDevice, Instance, Device), ) -> Result ``` Performs the conversion. ``` -------------------------------- ### Example: Last Element of Slice Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Demonstrates getting the last element of a slice using the `last` method, which returns an Option. ```rust let v = [10, 40, 30]; assert_eq!(Some(&30), v.last()); let w: &[i32] = &[]; assert_eq!(None, w.last()); ``` -------------------------------- ### VulkanObjects TryFrom Implementation with Device, Instance, and Queue Source: https://docs.rs/librashader/latest/librashader/runtime/vk/struct.VulkanObjects.html Allows creating a VulkanObjects instance from a tuple containing a PhysicalDevice, Instance, Device, and Queue. This is useful for initializing the Vulkan runtime with all necessary components. ```rust impl TryFrom<(PhysicalDevice, Instance, Device, Queue)> for VulkanObjects { type Error = FilterChainError; fn try_from( value: (PhysicalDevice, Instance, Device, Queue), ) -> Result { // ... implementation details ... } } ``` -------------------------------- ### Example: First Chunk of Slice Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Demonstrates getting the first N elements of a slice as an array reference using `first_chunk`. Returns None if the slice is too short. ```rust let u = [10, 40, 30]; assert_eq!(Some(&[10, 40]), u.first_chunk::<2>()); let v: &[i32] = &[10]; assert_eq!(None, v.first_chunk::<2>()); let w: &[i32] = &[]; assert_eq!(Some(&[]), w.first_chunk::<0>()); ``` -------------------------------- ### Initialize and Insert into FastHashMap Source: https://docs.rs/librashader/latest/librashader/type.FastHashMap.html Demonstrates the basic initialization of a FastHashMap and the insertion of key-value pairs. Shows how to check the map's length after operations. ```rust use halfbrown::HashMap; let mut a = HashMap::new(); assert_eq!(a.len(), 0); a.insert(1, "a"); assert_eq!(a.len(), 1); ``` -------------------------------- ### Get Element Offset in Slice Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Returns the index of an element reference within a slice. Returns `None` if the element does not point to the start of an element. This method uses pointer arithmetic and does not compare elements. ```rust let nums: &[u32] = &[1, 7, 1, 1]; let num = &nums[2]; assert_eq!(num, &1); assert_eq!(nums.element_offset(num), Some(2)); ``` ```rust let arr: &[[u32; 2]] = &[[0, 1], [2, 3]]; let flat_arr: &[u32] = arr.as_flattened(); let ok_elm: &[u32; 2] = flat_arr[0..2].try_into().unwrap(); let weird_elm: &[u32; 2] = flat_arr[1..3].try_into().unwrap(); assert_eq!(ok_elm, &[0, 1]); assert_eq!(weird_elm, &[1, 2]); assert_eq!(arr.element_offset(ok_elm), Some(0)); // Points to element 0 assert_eq!(arr.element_offset(weird_elm), None); // Points between element 0 and 1 ``` -------------------------------- ### Get Value from FastHashMap Source: https://docs.rs/librashader/latest/librashader/type.FastHashMap.html Illustrates how to retrieve a reference to a value associated with a key using the `get` method. It handles cases where the key may or may not exist in the map. ```rust use halfbrown::HashMap; let mut map = HashMap::new(); map.insert(1, "a"); assert_eq!(map.get(&1), Some(&"a")); assert_eq!(map.get(&2), None); ``` -------------------------------- ### Pointable::Init Source: https://docs.rs/librashader/latest/librashader/reflect/cross/struct.CrossHlslContext.html The type for initializers. ```APIDOC type Init = T ``` -------------------------------- ### Safe Element/Subslice Access with `get` Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Use `get` for safe access to elements or subslices by index or range. Returns `Some` with a reference if the index/range is valid, otherwise returns `None`. ```rust let v = [10, 40, 30]; assert_eq!(Some(&40), v.get(1)); assert_eq!(Some(&[10, 40][..]), v.get(0..2)); assert_eq!(None, v.get(3)); assert_eq!(None, v.get(0..4)); ``` -------------------------------- ### Pointable::init Source: https://docs.rs/librashader/latest/librashader/reflect/cross/struct.CrossHlslContext.html Initializes a with the given initializer. ```APIDOC unsafe fn init(init: ::Init) -> usize ``` -------------------------------- ### Getting File Metadata with `and_then` Source: https://docs.rs/librashader/latest/librashader/runtime/d3d11/error/type.Result.html Demonstrates using `and_then` to chain fallible operations, such as getting file metadata and then its modification time. Handles potential errors like file not found. ```rust use std::{io::ErrorKind, path::Path}; // Note: on Windows "/" maps to "C:\" let root_modified_time = Path::new("/").metadata().and_then(|md| md.modified()); assert!(root_modified_time.is_ok()); let should_fail = Path::new("/bad/path").metadata().and_then(|md| md.modified()); assert!(should_fail.is_err()); assert_eq!(should_fail.unwrap_err().kind(), ErrorKind::NotFound); ``` -------------------------------- ### Get Reference to Underlying Array Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Attempt to get a reference to the underlying array using `as_array`. Returns `Some` if the requested array size `N` exactly matches the slice length, otherwise returns `None`. ```rust let arr = [1, 2, 3]; let slice = &arr[..]; // This will succeed because N=3 matches slice length let array_ref: Option<&[i32; 3]> = slice.as_array::<3>(); assert!(array_ref.is_some()); // This will fail because N=2 does not match slice length let array_ref_fail: Option<&[i32; 2]> = slice.as_array::<2>(); assert!(array_ref_fail.is_none()); ``` -------------------------------- ### Get Last N Elements of a Slice Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Use `last_chunk` to get a reference to the last N elements of a slice as a fixed-size array. Returns `None` if the slice is shorter than N. Handles N=0 correctly. ```rust let u = [10, 40, 30]; assert_eq!(Some(&[40, 30]), u.last_chunk::<2>()); let v: &[i32] = &[10]; assert_eq!(None, v.last_chunk::<2>()); let w: &[i32] = &[]; assert_eq!(Some(&[]), w.last_chunk::<0>()); ``` -------------------------------- ### FromCompilation for DXIL Source: https://docs.rs/librashader/latest/librashader/reflect/trait.FromCompilation.html Implementation of FromCompilation for DXIL, allowing compilation from cached SPIRV. Available on Windows and with the 'd3d' crate feature. ```APIDOC ## impl FromCompilation, T> for DXIL ### Available on Windows and crate feature`d3d` only. ### Associated Types - `Target`: Type alias for `>::Target` - `Options`: Type alias for `>::Options` - `Context`: Type alias for `>::Context` - `Output`: Type alias for `>::Output ``` -------------------------------- ### VulkanObjects TryFrom Implementation with Device and Instance Source: https://docs.rs/librashader/latest/librashader/runtime/vk/struct.VulkanObjects.html Provides a way to construct VulkanObjects from a tuple containing a PhysicalDevice, Instance, and Device. This variant requires obtaining the queue separately. ```rust impl TryFrom<(PhysicalDevice, Instance, Device)> for VulkanObjects { type Error = FilterChainError; fn try_from( value: (PhysicalDevice, Instance, Device), ) -> Result { // ... implementation details ... } } ``` -------------------------------- ### type_id Source: https://docs.rs/librashader/latest/librashader/reflect/semantics/enum.UniqueSemantics.html Gets the `TypeId` of the current type. ```APIDOC ## type_id ### Description Gets the `TypeId` of `self`. ### Signature `fn type_id(&self) -> TypeId` ``` -------------------------------- ### BindingStage Initialization Methods Source: https://docs.rs/librashader/latest/librashader/reflect/semantics/struct.BindingStage.html Methods for creating and initializing BindingStage values. ```APIDOC ## BindingStage Initialization Methods ### `BindingStage::empty()` Returns a `BindingStage` with all bits unset. ### `BindingStage::all()` Returns a `BindingStage` with all known bits set. ### `BindingStage::from_bits(bits: u8)` Converts from a `u8` bitmask. Returns `None` if any unknown bits are set. ### `BindingStage::from_bits_truncate(bits: u8)` Converts from a `u8` bitmask, unsetting any unknown bits. ### `BindingStage::from_bits_retain(bits: u8)` Converts from a `u8` bitmask exactly. ### `BindingStage::from_name(name: &str)` Gets a `BindingStage` with the bits of a flag with the given name set. Returns `None` if `name` is empty or doesn’t correspond to any named flag. ``` -------------------------------- ### ShaderFeatures::type_id Source: https://docs.rs/librashader/latest/librashader/presets/struct.ShaderFeatures.html Gets the TypeId of the ShaderFeatures instance. ```APIDOC ## fn type_id(&self) -> TypeId ### Description Gets the `TypeId` of `self`. ### Returns - *TypeId* - The unique identifier for the type of `self`. ``` -------------------------------- ### Create WgpuOutputView from Raw Components Source: https://docs.rs/librashader/latest/librashader/runtime/wgpu/struct.WgpuOutputView.html Constructs a WgpuOutputView from an existing wgpu TextureView, a Size, and a TextureFormat. This is useful for creating an output view with specific properties. ```rust pub fn new_from_raw( view: &'a TextureView, size: Size, format: TextureFormat, ) -> WgpuOutputView<'a> ``` -------------------------------- ### Implement Any for T Source: https://docs.rs/librashader/latest/librashader/preprocess/struct.ShaderParameter.html Provides the ability to get the TypeId of a type. ```rust impl Any for T where T: 'static + ?Sized, Source§ #### fn type_id(&self) -> TypeId Gets the `TypeId` of `self`. Read more ``` -------------------------------- ### FilterChainVulkan::parameters Source: https://docs.rs/librashader/latest/librashader/runtime/vk/struct.FilterChain.html Gets the runtime parameters for this filter chain. ```APIDOC ## FilterChainVulkan::parameters ### Description Get the runtime parameters for this filter chain. ### Method `fn parameters(&self) -> &RuntimeParameters` ### Returns A reference to the `RuntimeParameters`. ``` -------------------------------- ### impl From<&Viewport> for Size Source: https://docs.rs/librashader/latest/librashader/runtime/struct.Size.html Implements conversion from &Viewport to Size. ```APIDOC ## impl From<&Viewport> for Size ### `fn from(value: &Viewport) -> Size` Converts to this type from the input type. ``` -------------------------------- ### RuntimeParameters::parameters Source: https://docs.rs/librashader/latest/librashader/runtime/struct.RuntimeParameters.html Get an immutable reference to the runtime parameters. ```APIDOC ## RuntimeParameters::parameters ### Description Get a reference to the runtime parameters. ### Signature ```rust pub fn parameters( &self, ) -> Arc, f32, BuildHasherDefault>> ``` ``` -------------------------------- ### RuntimeParameters::parameter_value Source: https://docs.rs/librashader/latest/librashader/runtime/struct.RuntimeParameters.html Get the value of a runtime parameter by its name. ```APIDOC ## RuntimeParameters::parameter_value ### Description Get the value of a runtime parameter. ### Signature ```rust pub fn parameter_value(&self, name: &str) -> Option ``` ``` -------------------------------- ### Use Entry API for In-place Updates Source: https://docs.rs/librashader/latest/librashader/type.FastHashMap.html Demonstrates the `entry` API for efficiently accessing and modifying map entries. It shows how to insert a default value if a key is not present and then update it. ```rust use halfbrown::HashMap; let mut letters = HashMap::new(); for ch in "a short treatise on fungi".chars() { let counter = letters.entry(ch).or_insert(0); *counter += 1; } assert_eq!(letters[&'s'], 2); assert_eq!(letters[&'t'], 3); assert_eq!(letters[&'u'], 1); assert_eq!(letters.get(&'y'), None); ``` -------------------------------- ### Get Semantic as String Source: https://docs.rs/librashader/latest/librashader/reflect/semantics/enum.UniqueSemantics.html Converts a `UniqueSemantics` variant to its string representation. ```rust pub const fn as_str(&self) -> &'static str ``` -------------------------------- ### Into Source: https://docs.rs/librashader/latest/librashader/reflect/semantics/struct.BindingStage.html Converts the instance into another type. ```APIDOC ## into ### Description Calls `U::from(self)`. This conversion is whatever the implementation of `From for U` chooses to do. ### Signature `fn into(self) -> U` ``` -------------------------------- ### type_id Source: https://docs.rs/librashader/latest/librashader/reflect/semantics/enum.TextureSemantics.html Gets the `TypeId` of `self`. This method is part of the `Any` trait implementation. ```APIDOC ## fn type_id(&self) -> TypeId ### Description Gets the `TypeId` of `self`. ### Method `type_id` ### Parameters None ### Response - **TypeId**: The type identifier of the object. ``` -------------------------------- ### Get Underlying Bits of BindingStage Source: https://docs.rs/librashader/latest/librashader/reflect/semantics/struct.BindingStage.html Retrieves the underlying bit representation of a BindingStage. ```APIDOC ## Get Underlying Bits of BindingStage ### Description Gets the underlying bits value of the BindingStage. ### Method `bits` ### Returns - `u8`: The underlying bits value. ``` -------------------------------- ### impl FromCompilation for WGSL Source: https://docs.rs/librashader/latest/librashader/reflect/struct.SpirvCompilation.html Allows conversion of SpirvCompilation to WGSL (WebGPU Shading Language) via Naga. ```APIDOC ### impl FromCompilation for WGSL Available on **non-crate feature`stable`** only. #### type Target = WGSL The target that the transformed object is expected to compile for. #### type Options = NagaLoweringOptions Options provided to the compiler. #### type Context = NagaWgslContext Additional context returned by the compiler after compilation. #### type Output = impl CompileReflectShader<>::Target, SpirvCompilation, Naga> The output type after conversion. #### fn from_compilation( compile: SpirvCompilation, ) -> Result>::Output>, ShaderReflectError> Tries to convert the input object into an object ready for compilation. ``` -------------------------------- ### gl_mip Method Source: https://docs.rs/librashader/latest/librashader/enum.FilterMode.html Gets the mipmap filtering mode for a given combination of FilterMode. ```APIDOC ## impl FilterMode ### pub fn gl_mip(&self, mip: FilterMode) -> u32 #### Description Get the mipmap filtering mode for the given combination. #### Parameters * **mip** (FilterMode) - The mipmap filtering mode to consider. #### Returns * (u32) - The corresponding mipmap filtering mode as a u32. ``` -------------------------------- ### impl From for Size Source: https://docs.rs/librashader/latest/librashader/runtime/struct.Size.html Implements conversion from Viewport to Size. ```APIDOC ## impl From for Size ### `fn from(value: Viewport) -> Size` Converts to this type from the input type. ``` -------------------------------- ### FromCompilation for DXIL Source: https://docs.rs/librashader/latest/librashader/reflect/trait.FromCompilation.html Implementation of `FromCompilation` for transforming SPIRV compilations into DXIL. ```rust impl FromCompilation for DXIL { type Target = DXIL; type Options = Option; type Context = (); type Output = impl CompileReflectShader<>::Target, SpirvCompilation, SpirvCross>; } ``` -------------------------------- ### strip_prefix Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Returns a subslice with the prefix removed if the slice starts with the specified prefix. ```APIDOC ## pub fn strip_prefix

(&self, prefix: &P) -> Option<&[T]> where P: SlicePattern + ?Sized, T: PartialEq, ### Description Returns a subslice with the prefix removed. If the slice starts with `prefix`, returns the subslice after the prefix, wrapped in `Some`. If `prefix` is empty, simply returns the original slice. If `prefix` is equal to the original slice, returns an empty slice. If the slice does not start with `prefix`, returns `None`. ### Parameters - `prefix`: The pattern to match as a prefix. ### Returns - `Some(subslice)` if the slice starts with the prefix. - `None` if the slice does not start with the prefix. ### Examples ```rust let v = &[10, 40, 30]; assert_eq!(v.strip_prefix(&[10]), Some(&[40, 30][..])); assert_eq!(v.strip_prefix(&[10, 40]), Some(&[30][..])); assert_eq!(v.strip_prefix(&[10, 40, 30]), Some(&[][..])); assert_eq!(v.strip_prefix(&[50]), None); assert_eq!(v.strip_prefix(&[10, 50]), None); let prefix : &str = "he"; assert_eq!(b"hello".strip_prefix(prefix.as_bytes()), Some(b"llo".as_ref())); ``` ``` -------------------------------- ### rchunks_exact Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Returns an iterator over chunks of a specified size, starting from the end, with no remainder. ```APIDOC ## pub fn rchunks_exact(&self, chunk_size: usize) -> RChunksExact<'_, T> ### Description Returns an iterator over `chunk_size` elements of the slice at a time, starting at the end of the slice. The chunks are slices and do not overlap. If `chunk_size` does not divide the length of the slice, then the last up to `chunk_size-1` elements will be omitted and can be retrieved from the `remainder` function of the iterator. ### Parameters * `chunk_size`: The desired size of each chunk. ### Returns An iterator yielding slices of exactly `chunk_size` elements. ### Panics Panics if `chunk_size` is zero. ``` -------------------------------- ### Load FilterChain from Preset Source: https://docs.rs/librashader/latest/librashader/runtime/wgpu/struct.FilterChain.html Loads a filter chain from a pre-parsed ShaderPreset. Requires a wgpu Device and Queue. ```rust pub fn load_from_preset( preset: ShaderPreset, device: &Device, queue: &Queue, options: Option<&FilterChainOptionsWgpu>, ) -> Result ``` -------------------------------- ### rchunks Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Returns an iterator over chunks of a specified size, starting from the end of the slice. ```APIDOC ## pub fn rchunks(&self, chunk_size: usize) -> RChunks<'_, T> ### Description Returns an iterator over `chunk_size` elements of the slice at a time, starting at the end of the slice. The chunks are slices and do not overlap. ### Parameters * `chunk_size`: The desired size of each chunk. ### Returns An iterator yielding slices of `chunk_size` elements. ### Panics Panics if `chunk_size` is zero. ### Examples ``` let slice = ['l', 'o', 'r', 'e', 'm']; let mut iter = slice.rchunks(2); assert_eq!(iter.next().unwrap(), &['e', 'm']); assert_eq!(iter.next().unwrap(), &['o', 'r']); assert_eq!(iter.next().unwrap(), &['l']); assert!(iter.next().is_none()); ``` ``` -------------------------------- ### From Implementation for Semantic to UniformBinding Source: https://docs.rs/librashader/latest/librashader/reflect/semantics/struct.Semantic.html Provides a conversion from `Semantic` to `UniformBinding`. ```APIDOC ## impl From> for UniformBinding ### Description Converts a `Semantic` into a `UniformBinding`. ### Methods - `from(value: Semantic) -> UniformBinding`: Converts to this type from the input type. ``` -------------------------------- ### iter Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Returns an iterator over the elements of the slice, yielding items from start to end. ```APIDOC ## pub fn iter(&self) -> Iter<'_, T> ### Description Returns an iterator over the slice. The iterator yields all items from start to end. ### Returns An `Iter<'_, T>` that yields references to the elements of the slice. ``` -------------------------------- ### Create BindingStage from Bits (Option) Source: https://docs.rs/librashader/latest/librashader/reflect/semantics/struct.BindingStage.html Attempts to create a BindingStage from a bit representation, returning None if unknown bits are present. ```APIDOC ## Create BindingStage from Bits (Option) ### Description Converts from a bits value. Returns `None` if any unknown bits are set. ### Method `from_bits` ### Parameters - `bits`: The `u8` bit representation. ### Returns - `Option`: An `Option` containing the BindingStage if the bits are valid, or `None`. ``` -------------------------------- ### LoadableResource Implementations Source: https://docs.rs/librashader/latest/librashader/presets/trait.LoadableResource.html Examples of how the LoadableResource trait is implemented for different resource types. ```APIDOC ### impl LoadableResource for PassMeta - `ResourceType`: `ShaderSource` - `Error`: `PreprocessError` - `Options`: `ShaderFeatures` ### impl LoadableResource for TextureMeta - `ResourceType`: `TextureBuffer` - `Error`: `ImageError` - `Options`: `()` ``` -------------------------------- ### TryFrom for VulkanObjects Source: https://docs.rs/librashader/latest/librashader/runtime/vk/struct.VulkanObjects.html Allows creating a VulkanObjects instance from a VulkanInstance. ```APIDOC ### impl TryFrom for VulkanObjects ```rust fn try_from(vulkan: VulkanInstance) -> Result ``` Performs the conversion. ``` -------------------------------- ### Load FilterChain from Path Source: https://docs.rs/librashader/latest/librashader/runtime/wgpu/struct.FilterChain.html Loads a shader preset from a given file path into a filter chain. Requires ShaderFeatures, a wgpu Device, and Queue. ```rust pub fn load_from_path( path: impl AsRef, features: ShaderFeatures, device: &Device, queue: &Queue, options: Option<&FilterChainOptionsWgpu>, ) -> Result ``` -------------------------------- ### entry Source: https://docs.rs/librashader/latest/librashader/type.FastHashMap.html Gets the given key’s corresponding entry in the map for in-place manipulation. ```APIDOC ## entry ### Description Gets the given key’s corresponding entry in the map for in-place manipulation. ### Method `entry(&mut self, key: K) -> Entry<'_, K, V, VEC_LIMIT_UPPER, S>` ### Constraints `S: Default` ### Example ```rust use halfbrown::HashMap; let mut letters = HashMap::new(); for ch in "a short treatise on fungi".chars() { let counter = letters.entry(ch).or_insert(0); *counter += 1; } assert_eq!(letters[&'s'], 2); assert_eq!(letters[&'t'], 3); assert_eq!(letters[&'u'], 1); assert_eq!(letters.get(&'y'), None); ``` ``` -------------------------------- ### FromCompilation for WGSL Source: https://docs.rs/librashader/latest/librashader/reflect/naga/struct.Naga.html Implementation of `FromCompilation` for converting SPIR-V compilations to WGSL target using Naga. ```APIDOC ### impl FromCompilation for WGSL Available on **non-crate feature`stable`** only. #### fn from_compilation( compile: SpirvCompilation, ) -> Result>::Output>, ShaderReflectError> Tries to convert the input object into an object ready for compilation. ``` -------------------------------- ### Get Slice Length Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Returns the number of elements in the slice. This is a standard method for slices. ```rust pub fn len(&self) -> usize ``` -------------------------------- ### Implement CloneToUninit for T (Nightly) Source: https://docs.rs/librashader/latest/librashader/preprocess/struct.ShaderParameter.html Nightly-only experimental API for copying data to uninitialized memory. ```rust impl CloneToUninit for T where T: Clone, Source§ #### unsafe fn clone_to_uninit(&self, dest: *mut u8) 🔬This is a nightly-only experimental API. (`clone_to_uninit`) Performs copy-assignment from `self` to `dest`. Read more ``` -------------------------------- ### Get All Runtime Parameters Source: https://docs.rs/librashader/latest/librashader/runtime/struct.RuntimeParameters.html Returns an Arc reference to the collection of all current runtime parameters. ```rust pub fn parameters( &self, ) -> Arc, f32, BuildHasherDefault>> ``` -------------------------------- ### Get FilterChain Runtime Parameters Source: https://docs.rs/librashader/latest/librashader/runtime/d3d11/struct.FilterChain.html Retrieves the runtime parameters associated with the filter chain. ```rust fn parameters(&self) -> &RuntimeParameters ``` -------------------------------- ### Create BindingStage with All Bits Set Source: https://docs.rs/librashader/latest/librashader/reflect/semantics/struct.BindingStage.html Creates a BindingStage with all known bits set. ```APIDOC ## Create BindingStage with All Bits Set ### Description Gets a flags value with all known bits set. ### Method `all` ### Returns - `Self`: A BindingStage with all known bits set. ``` -------------------------------- ### CloneToUninit Source: https://docs.rs/librashader/latest/librashader/reflect/semantics/struct.BindingStage.html Performs copy-assignment to an uninitialized memory location. This is a nightly-only experimental API. ```APIDOC ## clone_to_uninit ### Description Performs copy-assignment from `self` to `dest`. ### Signature `unsafe fn clone_to_uninit(&self, dest: *mut u8)` ### Stability Nightly-only experimental API. ``` -------------------------------- ### Get Uniform Binding Type Source: https://docs.rs/librashader/latest/librashader/reflect/semantics/enum.UniqueSemantics.html Retrieves the `UniformType` for a `UniqueSemantics` variant, indicating how it should be bound. ```rust pub const fn binding_type(&self) -> UniformType ``` -------------------------------- ### Index> Source: https://docs.rs/librashader/latest/librashader/type.ShortString.html Allows indexing into SmartString with a range starting from a specific index. ```APIDOC ## fn index( &self, index: RangeFrom, ) -> & as Index>>::Output ### Description Performs the indexing (`container[index]`) operation. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **str** - The substring corresponding to the index. #### Response Example None ``` -------------------------------- ### as_rchunks Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Splits the slice into a slice of N-element arrays starting from the end, and a remainder slice. ```APIDOC ## pub fn as_rchunks(&self) -> (&[T], &[[T; N]]) ### Description Splits the slice into a slice of `N`-element arrays, starting at the end of the slice, and a remainder slice with length strictly less than `N`. ### Parameters * `N`: A const generic parameter specifying the size of each chunk array. ### Returns A tuple containing: * A remainder slice (`&[T]`) with length strictly less than `N`. * A slice of `N`-element arrays (`&[[T; N]]`). ### Panics Panics if `N` is zero. ### Examples ``` let slice = ['l', 'o', 'r', 'e', 'm']; let (remainder, chunks) = slice.as_rchunks::<2>(); assert_eq!(remainder, &['l']); assert_eq!(chunks, &[['o', 'r'], ['e', 'm']]); ``` ``` -------------------------------- ### FromCompilation for GLSL Source: https://docs.rs/librashader/latest/librashader/reflect/targets/struct.GLSL.html Implementation of `FromCompilation` for converting SPIR-V to GLSL using `SpirvCross`. This is available on non-crate feature `stable`. ```APIDOC ### impl FromCompilation for GLSL Available on **non-crate feature `stable`** only. #### Type Aliases - `type Target = GLSL` - `type Options = GlslVersion` - `type Context = CrossGlslContext` - `type Output = impl CompileReflectShader` #### Methods - `fn from_compilation(compile: SpirvCompilation) -> Result, ShaderReflectError>` Tries to convert the input object into an object ready for compilation. ``` -------------------------------- ### Binary Search with Partition Point for Range Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Shows how to use `partition_point` in conjunction with `binary_search` to find the range of matching elements in a sorted slice. ```rust let s = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]; let low = s.partition_point(|x| x < &1); assert_eq!(low, 1); let high = s.partition_point(|x| x <= &1); assert_eq!(high, 5); let r = s.binary_search(&1); assert!((low..high).contains(&r.unwrap())); assert!(s[..low].iter().all(|&x| x < 1)); assert!(s[low..high].iter().all(|&x| x == 1)); assert!(s[high..].iter().all(|&x| x > 1)); // For something not found, the "range" of equal items is empty assert_eq!(s.partition_point(|x| x < &11), 9); assert_eq!(s.partition_point(|x| x <= &11), 9); assert_eq!(s.binary_search(&11), Err(9)); ``` -------------------------------- ### impl From<&Texture> for WgpuOutputView<'static> Source: https://docs.rs/librashader/latest/librashader/runtime/wgpu/struct.WgpuOutputView.html Converts a Texture into a WgpuOutputView. ```APIDOC ## fn from(image: &Texture) -> WgpuOutputView<'static> Converts to this type from the input type. ``` -------------------------------- ### WgpuOutputView::new_from_raw Source: https://docs.rs/librashader/latest/librashader/runtime/wgpu/struct.WgpuOutputView.html Creates a new WgpuOutputView from an existing wgpu TextureView, size, and format. ```APIDOC ## pub fn new_from_raw( view: &'a TextureView, size: Size, format: TextureFormat, ) -> WgpuOutputView<'a> Create an output view from an existing texture view, size, and format. ``` -------------------------------- ### FilterChainWgpu::load_from_preset_deferred Source: https://docs.rs/librashader/latest/librashader/runtime/wgpu/struct.FilterChain.html Loads a FilterChainWgpu from a ShaderPreset, deferring GPU initialization. This method requires careful handling of the CommandEncoder. Requires 'runtime' and 'runtime-wgpu' features. ```APIDOC ## pub fn load_from_preset_deferred( preset: ShaderPreset, device: &Device, queue: &Queue, cmd: &mut CommandEncoder, options: Option<&FilterChainOptionsWgpu>, ) -> Result ### Description Load a filter chain from a pre-parsed `ShaderPreset`, deferring and GPU-side initialization to the caller. This function therefore requires no external synchronization of the device queue. ### Safety The provided command buffer must be ready for recording and contain no prior commands. The caller is responsible for ending the command buffer and immediately submitting it to a graphics queue. The command buffer must be completely executed before calling `frame`. ### Parameters - `preset`: The `ShaderPreset` to load. - `device`: The wgpu device. - `queue`: The wgpu queue. - `cmd`: A mutable reference to the `CommandEncoder` for recording commands. - `options`: Optional wgpu-specific filter chain options. ``` -------------------------------- ### Pointable Source: https://docs.rs/librashader/latest/librashader/reflect/semantics/struct.BindingStage.html Provides methods for pointer manipulation and initialization. ```APIDOC ### impl Pointable for T #### const ALIGN: usize The alignment of pointer. #### type Init = T The type for initializers. #### unsafe fn init(init: ::Init) -> usize Initializes a with the given initializer. Read more #### unsafe fn deref<'a>(ptr: usize) -> &'a T Dereferences the given pointer. Read more #### unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T Mutably dereferences the given pointer. Read more #### unsafe fn drop(ptr: usize) Drops the object pointed to by the given pointer. Read more ``` -------------------------------- ### Get Runtime Parameter Value Source: https://docs.rs/librashader/latest/librashader/runtime/struct.RuntimeParameters.html Retrieves the current value of a specific runtime parameter by its name. ```rust pub fn parameter_value(&self, name: &str) -> Option ``` -------------------------------- ### unique_semantic Source: https://docs.rs/librashader/latest/librashader/reflect/semantics/trait.UniqueSemanticMap.html Get the unique semantic for the given variable name. This method is part of the UniqueSemanticMap trait. ```APIDOC ## fn unique_semantic(&self, name: &str) -> Option> ### Description Get the unique semantic for the given variable name. ### Method Signature `fn unique_semantic(&self, name: &str) -> Option>` ### Parameters * `name` (&str): The name of the variable for which to retrieve the semantic. ### Returns * `Option>`: An Option containing the Semantic if found, otherwise None. ``` -------------------------------- ### FromCompilation for DXIL Source: https://docs.rs/librashader/latest/librashader/reflect/targets/struct.DXIL.html Implementation of `FromCompilation` for converting a SPIR-V compilation to DXIL using SpirvCross. This is available on non-crate feature `stable`. ```APIDOC ### impl FromCompilation for DXIL Available on **non-crate feature`stable`** only. #### type Target = DXIL The target that the transformed object is expected to compile for. #### type Options = Option Options provided to the compiler. #### type Context = () Additional context returned by the compiler after compilation. #### type Output = impl CompileReflectShader<>::Target, SpirvCompilation, SpirvCross> The output type after conversion. #### fn from_compilation( compile: SpirvCompilation, ) -> Result>::Output>, ShaderReflectError> Tries to convert the input object into an object ready for compilation. ``` -------------------------------- ### get_parameter_meta Source: https://docs.rs/librashader/latest/librashader/presets/fn.get_parameter_meta.html Get full parameter metadata from a shader preset. Available on crate feature `presets` only. ```APIDOC ## Function get_parameter_meta ### Description Get full parameter metadata from a shader preset. ### Signature ```rust pub fn get_parameter_meta( preset: &ShaderPreset, ) -> Result, PreprocessError> ``` ### Availability Available on **crate feature `presets`** only. ``` -------------------------------- ### IndexMut> Source: https://docs.rs/librashader/latest/librashader/type.ShortString.html Allows mutable indexing into SmartString with a range starting from a specific index. ```APIDOC ## fn index_mut( &mut self, index: RangeFrom, ) -> &mut as Index>>::Output ### Description Performs the mutable indexing (`container[index]`) operation. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **&mut str** - A mutable reference to the substring. #### Response Example None ``` -------------------------------- ### SmartString::as_str - Get String Slice Reference Source: https://docs.rs/librashader/latest/librashader/type.ShortString.html Provides an immutable reference to the string as a string slice. ```rust pub fn as_str(&self) -> &str ``` -------------------------------- ### into_ok Source: https://docs.rs/librashader/latest/librashader/runtime/d3d11/error/type.Result.html Returns the contained Ok value, never panics. This is a nightly-only experimental API. ```APIDOC ## into_ok ### Description Returns the contained `Ok` value, but never panics. This method is known to never panic on the result types it is implemented for, making it a maintainability safeguard. ### Method Signature `pub const fn into_ok(self) -> T where E: Into` ### Note This is a nightly-only experimental API. ### Examples ```rust fn only_good_news() -> Result { Ok("this is fine".into()) } let s: String = only_good_news().into_ok(); println!("{s}"); ``` ``` -------------------------------- ### as_array Source: https://docs.rs/librashader/latest/librashader/reflect/dxil/struct.DxilObject.html Attempts to get a reference to the underlying array if its length matches N. Returns None otherwise. ```APIDOC ## pub fn as_array(&self) -> Option<&[T; N]> ### Description Gets a reference to the underlying array. If `N` is not exactly equal to the length of `self`, then this method returns `None`. ### Parameters * `N`: Generic constant specifying the expected length of the array. ### Returns An `Option` containing a reference to the array if its length is `N`, otherwise `None`. ```