### Get Default CompressedLightCube Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.CompressedLightCube.html Initializes a CompressedLightCube with its default values. This is often used for creating a new, empty cube. ```rust fn default() -> CompressedLightCube Returns the “default value” for a type. Read more ``` -------------------------------- ### Default Implementation for CompressedLightCube Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.CompressedLightCube.html Provides a method to get the default value for CompressedLightCube. ```APIDOC ### impl Default for CompressedLightCube #### fn default() -> CompressedLightCube Returns the “default value” for a type. ``` -------------------------------- ### Getting Metadata with and_then Source: https://docs.rs/vbsp/0.9.1/vbsp/type.BspResult.html Demonstrates using `and_then` with file system metadata operations. It shows how to handle both successful retrieval of metadata and 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); ``` -------------------------------- ### Deprecated Description Method for UnsupportedLumpVersion Source: https://docs.rs/vbsp/0.9.1/vbsp/error/struct.UnsupportedLumpVersion.html Deprecated method for getting a string description of the error. Use the Display implementation or `to_string()` instead. ```rust fn description(&self) -> &str ``` -------------------------------- ### Checking if a slice starts with a prefix Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Leaves.html Use `starts_with` to determine if a slice begins with a given sequence of elements. An empty slice is always considered a prefix. ```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])); ``` -------------------------------- ### Get Entry from Packfile Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Packfile.html Retrieves the content of a specific entry by name from the packfile. Returns a BspResult with an Option containing the entry data. ```rust pub fn get(&self, name: &str) -> BspResult>> ``` -------------------------------- ### Get First Element of Slice Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Leaves.html Returns the first element of the slice as an `Option<&T>`, or `None` if the slice is empty. Useful for peeking at the start of a collection. ```rust let v = [10, 40, 30]; assert_eq!(Some(&10), v.first()); let w: &[i32] = &[]; assert_eq!(None, w.first()); ``` -------------------------------- ### Remove a prefix from a slice Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Leaves.html Use `strip_prefix` to get a subslice after removing a specified prefix. Returns `None` if the slice does not start with the prefix. Handles empty prefixes and prefixes equal to the entire slice. ```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); ``` ```rust let prefix : &str = "he"; assert_eq!(b"hello".strip_prefix(prefix.as_bytes()), Some(b"llo".as_ref())); ``` -------------------------------- ### Clone Implementation for CompressedLightCube Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.CompressedLightCube.html Provides methods for cloning CompressedLightCube instances. ```APIDOC ### impl Clone for CompressedLightCube #### fn clone(&self) -> CompressedLightCube Returns a duplicate of the value. #### fn clone_from(&mut self, source: &Self) Performs copy-assignment from `source`. ``` -------------------------------- ### Get Element Index from Reference Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Leaves.html The `element_offset` method returns the index of an element within a slice given a reference to it. It uses pointer arithmetic and returns `None` if the reference does not point to the start of an element. This method panics if `T` is zero-sized. ```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 ``` -------------------------------- ### Handle Source: https://docs.rs/vbsp/0.9.1/vbsp/struct.Handle.html Generic Handle constructor. ```APIDOC ## Handle ### Description Generic Handle constructor. ### Methods #### `new` Creates a new Handle. ### Parameters #### Path Parameters - **bsp** (*&'a Bsp*) - Required - A reference to the Bsp file. - **data** (*&'a T*) - Required - A reference to the data structure. ``` -------------------------------- ### Get Underlying Array if Length Matches Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Leaves.html Attempt to get a reference to the underlying array using `as_array`. This returns `Some` only if the requested array length `N` exactly matches the slice's length. ```rust let x = &[1, 2, 4]; let arr: Option<&[i32; 3]> = x.as_array(); ``` -------------------------------- ### StaticPropLumpFlags Initialization Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.StaticPropLumpFlags.html Methods for creating and initializing StaticPropLumpFlags. ```APIDOC ## StaticPropLumpFlags Initialization ### Description Methods for creating and initializing StaticPropLumpFlags. ### Methods - `empty()`: Returns a `StaticPropLumpFlags` with all bits unset. - `all()`: Returns a `StaticPropLumpFlags` with all known bits set. - `from_bits(bits: u32)`: Converts from a `u32` bitmask, returning `None` if unknown bits are set. - `from_bits_truncate(bits: u32)`: Converts from a `u32` bitmask, truncating any unknown bits. - `from_bits_retain(bits: u32)`: Converts from a `u32` bitmask, retaining all bits exactly. - `from_name(name: &str)`: Creates flags from a flag name, returning `None` if the name is invalid. ``` -------------------------------- ### impl CloneToUninit for T Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Angles.html Nightly-only experimental API for copying data to uninitialized memory. ```APIDOC ## unsafe fn clone_to_uninit(&self, dest: *mut u8) ### Description Performs copy-assignment from `self` to `dest`. ### Method POST ### Endpoint N/A (Method on struct) ### Parameters - **dest** (*mut u8) - Required - A raw pointer to the destination memory. ### Response None (operation is unsafe) ``` -------------------------------- ### GameLumpFlags::bits Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.GameLumpFlags.html Get the underlying bits value. ```APIDOC ## GameLumpFlags::bits ### Description Get the underlying bits value. The returned value is exactly the bits set in this flags value. ### Method `const fn bits(&self) -> u16` ``` -------------------------------- ### Bsp::root_node Source: https://docs.rs/vbsp/0.9.1/vbsp/struct.Bsp.html Gets the root node of the BSP tree. ```APIDOC ## Bsp::root_node ### Description Get the root node of the bsp. ### Signature `pub fn root_node(&self) -> Handle<'_, Node>` ### Returns A `Handle` to the root `Node` of the BSP. ``` -------------------------------- ### Into Ok Value (Nightly) Source: https://docs.rs/vbsp/0.9.1/vbsp/type.BspResult.html Use `into_ok()` to safely retrieve the `Ok` value without panicking. This is an experimental API and requires nightly Rust. ```rust fn only_good_news() -> Result { Ok("this is fine".into()) } let s: String = only_good_news().into_ok(); println!("{s}"); ``` -------------------------------- ### Implement CloneToUninit for T Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Color.html Nightly-only experimental API for performing copy-assignment to uninitialized memory. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### GameLumpFlags::empty Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.GameLumpFlags.html Get a flags value with all bits unset. ```APIDOC ## GameLumpFlags::empty ### Description Get a flags value with all bits unset. ### Method `const fn empty() -> Self` ``` -------------------------------- ### BinRead Implementation for CompressedLightCube Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.CompressedLightCube.html Provides methods for reading CompressedLightCube data from a binary reader, supporting different endianness and arguments. ```APIDOC ### impl BinRead for CompressedLightCube #### fn read_options( __binrw_generated_var_reader: &mut R, __binrw_generated_var_endian: Endian, __binrw_generated_var_arguments: Self::Args<'_>, ) -> BinResult Read `Self` from the reader using the given `Endian` and arguments. #### fn read_be(reader: &mut R) -> Result Read `Self` from the reader using default arguments and assuming big-endian byte order. #### fn read_le(reader: &mut R) -> Result Read `Self` from the reader using default arguments and assuming little-endian byte order. #### fn read_ne(reader: &mut R) -> Result Read `T` from the reader assuming native-endian byte order. #### fn read_be_args(reader: &mut R, args: Self::Args<'_>) -> Result Read `Self` from the reader, assuming big-endian byte order, using the given arguments. #### fn read_le_args(reader: &mut R, args: Self::Args<'_>) -> Result Read `Self` from the reader, assuming little-endian byte order, using the given arguments. #### fn read_ne_args(reader: &mut R, args: Self::Args<'_>) -> Result Read `T` from the reader, assuming native-endian byte order, using the given arguments. ``` -------------------------------- ### impl Any for T Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.DisplacementVertex.html Provides the `type_id` method to get the `TypeId` of an object. ```APIDOC ## fn type_id(&self) -> TypeId ### Description Gets the `TypeId` of `self`. ### Method `type_id` ``` -------------------------------- ### GameLumpFlags::all Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.GameLumpFlags.html Get a flags value with all known bits set. ```APIDOC ## GameLumpFlags::all ### Description Get a flags value with all known bits set. ### Method `const fn all() -> Self` ``` -------------------------------- ### Read CompressedLightCube with BinRead (Default) Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.CompressedLightCube.html Reads a CompressedLightCube from a binary reader using default arguments and assuming little-endian byte order. Ensure the reader is properly set up and the data format matches. ```rust fn read_le(reader: &mut R) -> Result where R: Read + Seek, Self::Args<'a>: for<'a> Required, Read `Self` from the reader using default arguments and assuming little-endian byte order. Read more ``` -------------------------------- ### impl Any for T Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.DisplacementTriangle.html Provides the `type_id` method to get the unique identifier of a type. ```APIDOC ## fn type_id(&self) -> TypeId ### Description Gets the `TypeId` of `self`. ### Parameters None ### Returns - `TypeId`: The unique identifier of the type. ``` -------------------------------- ### CloneToUninit Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Directories.html Performs copy-assignment from self to an uninitialized memory location. This is an experimental API. ```APIDOC ## unsafe fn clone_to_uninit(&self, dest: *mut u8) ### Description 🔬This is a nightly-only experimental API. (`clone_to_uninit`) Performs copy-assignment from `self` to `dest`. ### Method POST (conceptual) ### Endpoint N/A (SDK method) ### Parameters - **dest** (*mut u8) - Required - A raw pointer to the destination memory location. ### Response None (operation modifies memory directly) ``` -------------------------------- ### Implement Any trait for T Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Color.html Provides the type_id method to get the TypeId of a value. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### iter Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Leaves.html Returns an iterator over the slice, yielding all items from start to end. ```APIDOC ## iter(&self) -> Iter<'_, T> ### Description Returns an iterator over the slice. ### Details The iterator yields all items from start to end. ### Examples ``` let x = &[1, 2, 4]; let mut iterator = x.iter(); assert_eq!(iterator.next(), Some(&1)); assert_eq!(iterator.next(), Some(&2)); assert_eq!(iterator.next(), Some(&4)); assert_eq!(iterator.next(), None); ``` ``` -------------------------------- ### Read CompressedLightCube with BinRead and Arguments Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.CompressedLightCube.html Reads a CompressedLightCube from a binary reader, assuming little-endian byte order, using the provided arguments. This allows for custom parsing logic. ```rust fn read_le_args(reader: &mut R, args: Self::Args<'_>) -> Result where R: Read + Seek, Read `Self` from the reader, assuming little-endian byte order, using the given arguments. Read more ``` -------------------------------- ### Debug Implementation for CompressedLightCube Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.CompressedLightCube.html Provides a method for formatting CompressedLightCube instances for debugging. ```APIDOC ### impl Debug for CompressedLightCube #### fn fmt(&self, f: &mut Formatter<'_>) -> Result Formats the value using the given formatter. ``` -------------------------------- ### impl TryFrom for T Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.CompressedLightCube.html Provides a blanket implementation for TryFrom. ```APIDOC ## Blanket Implementations ### impl TryFrom for T This blanket implementation allows attempting to convert from type `U` to type `T` if `U` implements `Into`. #### type Error = Infallible The type returned in the event of a conversion error. `Infallible` indicates that this conversion cannot fail. #### fn try_from(value: U) -> Result>::Error> Performs the conversion. This method attempts to convert `value` from type `U` to type `T`. ``` -------------------------------- ### Get Slice Length Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Leaves.html Returns the number of elements in the slice. This is a common operation for collections. ```rust let a = [1, 2, 3]; assert_eq!(a.len(), 3); ``` -------------------------------- ### rchunks_exact Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Leaves.html Returns an iterator over `chunk_size` elements of the slice at a time, starting at the end of the slice. ```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. ### Panics Panics if `chunk_size` is zero. ### Examples ``` let slice = ['l', 'o', 'r', 'e', 'm']; let mut iter = slice.rchunks_exact(2); assert_eq!(iter.next().unwrap(), &['e', 'm']); assert_eq!(iter.next().unwrap(), &['o', 'r']); assert!(iter.next().is_none()); assert_eq!(iter.remainder(), &['l']); ``` ``` -------------------------------- ### starts_with Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Leaves.html Returns `true` if `needle` is a prefix of the slice or equal to the slice. ```APIDOC ## starts_with(&self, needle: &[T]) -> bool ### Description Returns `true` if `needle` is a prefix of the slice or equal to the slice. ### Parameters #### Path Parameters - **needle** (&[T]) - Required - The slice to check if it is a prefix. ### Response - **bool** - `true` if `needle` is a prefix of the slice, `false` otherwise. ``` -------------------------------- ### rchunks Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Leaves.html Returns an iterator over `chunk_size` elements of the slice at a time, starting at 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. ### 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()); ``` ``` -------------------------------- ### Clone Implementation for Directories Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Directories.html Provides methods for creating a duplicate of a Directories instance. ```rust fn clone(&self) -> Directories fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### array_windows Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Leaves.html Returns an iterator over overlapping windows of `N` elements of a slice, starting at the beginning of the slice. ```APIDOC ## pub fn array_windows(&self) -> ArrayWindows<'_, T, N> ### Description Returns an iterator over overlapping windows of `N` elements of a slice, starting at the beginning of the slice. This is the const generic equivalent of `windows`. ### Panics Panics if `N` is zero. ### Examples ``` let slice = [0, 1, 2, 3]; let mut iter = slice.array_windows(); assert_eq!(iter.next().unwrap(), &[0, 1]); assert_eq!(iter.next().unwrap(), &[1, 2]); assert_eq!(iter.next().unwrap(), &[2, 3]); assert!(iter.next().is_none()); ``` ``` -------------------------------- ### impl Sync for CompressedLightCube Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.CompressedLightCube.html Indicates that CompressedLightCube can be safely shared across threads. ```APIDOC ## Auto Trait Implementations ### impl Sync for CompressedLightCube This implementation confirms that `CompressedLightCube` implements the `Sync` trait, allowing references to instances of this type to be safely shared across multiple threads concurrently. ``` -------------------------------- ### as_array Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Leaves.html Gets a reference to the underlying array if the requested size `N` exactly matches the slice length. ```APIDOC ## as_array(&self) -> Option<&[T; N]> ### Description Gets a reference to the underlying array. ### Details If `N` is not exactly equal to the length of `self`, then this method returns `None`. ``` -------------------------------- ### take Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.EntitiesIter.html Creates an iterator that yields the first `n` elements, or fewer if the underlying iterator ends sooner. ```APIDOC ## fn take(self, n: usize) -> Take ### Description Creates an iterator that yields the first `n` elements, or fewer if the underlying iterator ends sooner. ### Method `take` ### Parameters #### Path Parameters - **n** (usize) - Required - The maximum number of elements to yield. ``` -------------------------------- ### CloneToUninit Trait Implementation (Nightly) Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.LightColor.html An experimental nightly-only API that allows copying `LightColor` data directly into uninitialized memory. Use with caution as it requires unsafe operations. ```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 Source ``` -------------------------------- ### Get k smallest elements Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.EntitiesIter.html Sorts the k smallest elements into a new iterator, in ascending order. ```rust fn k_smallest(self, k: usize) -> IntoIter where Self: Sized, Self::Item: Ord, ``` -------------------------------- ### impl CloneToUninit for T Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.DisplacementTriangle.html Provides an unsafe method for cloning data into uninitialized memory. This is an experimental API. ```APIDOC ## unsafe fn clone_to_uninit(&self, dest: *mut u8) ### Description Performs copy-assignment from `self` to `dest`. ### Parameters - `dest` (*mut u8): A pointer to the destination memory location. ### Safety This method is unsafe and requires the caller to ensure that `dest` is valid and points to enough uninitialized memory to hold the cloned data. ``` -------------------------------- ### Get FixedString as &str Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.FixedString.html Converts the FixedString into a string slice. This is useful for reading or displaying the string content. ```rust pub fn as_str(&self) -> &str ``` -------------------------------- ### Unwrap Error Value Source: https://docs.rs/vbsp/0.9.1/vbsp/type.BspResult.html Use `unwrap_err()` to get the contained `Err` value. This method will panic if the `Result` is an `Ok`. ```rust let x: Result = Ok(2); x.unwrap_err(); // panics with `2` ``` ```rust let x: Result = Err("emergency failure"); assert_eq!(x.unwrap_err(), "emergency failure"); ``` -------------------------------- ### impl CloneToUninit for T Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.VertNormal.html An experimental, nightly-only API for performing copy-assignment from `self` to an uninitialized memory location pointed to by `dest`. Requires `T` to implement `Clone`. ```APIDOC ## unsafe fn clone_to_uninit(&self, dest: *mut u8) ### Description 🔬 This is a nightly-only experimental API. Performs copy-assignment from `self` to the memory location pointed to by `dest`. ### Method N/A (Trait method) ### Parameters - **self** (&T) - A reference to the value to be cloned. - **dest** (*mut u8) - A raw pointer to the uninitialized memory location where the cloned value will be placed. ``` -------------------------------- ### Unwrap Ok Value Source: https://docs.rs/vbsp/0.9.1/vbsp/type.BspResult.html Use `unwrap()` to get the contained `Ok` value. This method will panic if the `Result` is an `Err`. ```rust let x: Result = Ok(2); assert_eq!(x.unwrap(), 2); ``` ```rust let x: Result = Err("emergency failure"); x.unwrap(); // panics with `emergency failure` ``` -------------------------------- ### impl From for T Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.CompressedLightCube.html Provides a trivial implementation of From for T. ```APIDOC ## Blanket Implementations ### impl From for T This blanket implementation provides a `From` trait for any type `T`. #### fn from(t: T) -> T Returns the argument unchanged. This is a trivial conversion where the source and target types are the same. ``` -------------------------------- ### into_ok Source: https://docs.rs/vbsp/0.9.1/vbsp/type.BspResult.html Returns the contained `Ok` value, but never panics. This is an experimental API. ```APIDOC ## pub const fn into_ok(self) -> T ### Description Returns the contained `Ok` value, but never panics. This is a nightly-only experimental API. ### Method `into_ok` ### Parameters None ### Request Example ```rust fn only_good_news() -> Result { Ok("this is fine".into()) } let s: String = only_good_news().into_ok(); println!("{s}"); ``` ### Response Returns the `Ok` value. ``` -------------------------------- ### Mutating Slice Windows with Cells Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Leaves.html Demonstrates how to use `Cell::as_slice_of_cells` in conjunction with `windows` to perform in-place mutations on slice windows, as a direct `windows_mut` is not possible due to lifetime constraints. ```rust use std::cell::Cell; let mut array = ['R', 'u', 's', 't', ' ', '2', '0', '1', '5']; let slice = &mut array[..]; let slice_of_cells: &[Cell] = Cell::from_mut(slice).as_slice_of_cells(); for w in slice_of_cells.windows(3) { Cell::swap(&w[0], &w[2]); } assert_eq!(array, ['s', 't', ' ', '2', '0', '1', '5', 'u', 'R']); ``` -------------------------------- ### Get RawEntity as String Slice Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.RawEntity.html Converts the RawEntity into a string slice. This method returns a reference to the underlying string data. ```rust pub fn as_str(&self) -> &'a str ``` -------------------------------- ### Get k smallest elements by key Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.EntitiesIter.html Returns the elements producing the k smallest outputs of the provided key extraction function. ```rust fn k_smallest_by_key(self, k: usize, key: F) -> IntoIter where Self: Sized, F: FnMut(&Self::Item) -> K, K: Ord, ``` -------------------------------- ### BinRead Implementation for LeafV1 Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.LeafV1.html Details on how to read LeafV1 data from a binary source, supporting different endianness and argument configurations. ```APIDOC ### impl BinRead for LeafV1 #### fn read_options( __binrw_generated_var_reader: &mut R, __binrw_generated_var_endian: Endian, __binrw_generated_var_arguments: Self::Args<'_>, ) -> BinResult Reads `Self` from the reader using the given `Endian` and arguments. #### fn read_be(reader: &mut R) -> Result Reads `Self` from the reader using default arguments and assuming big-endian byte order. #### fn read_le(reader: &mut R) -> Result Reads `Self` from the reader using default arguments and assuming little-endian byte order. #### fn read_ne(reader: &mut R) -> Result Reads `T` from the reader assuming native-endian byte order. #### fn read_be_args(reader: &mut R, args: Self::Args<'_>) -> Result Reads `Self` from the reader, assuming big-endian byte order, using the given arguments. #### fn read_le_args(reader: &mut R, args: Self::Args<'_>) -> Result Reads `Self` from the reader, assuming little-endian byte order, using the given arguments. #### fn read_ne_args(reader: &mut R, args: Self::Args<'_>) -> Result Reads `T` from the reader, assuming native-endian byte order, using the given arguments. ``` -------------------------------- ### Get k smallest elements by comparison Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.EntitiesIter.html Sorts the k smallest elements into a new iterator using the provided comparison function. ```rust fn k_smallest_by(self, k: usize, cmp: F) -> IntoIter where Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> Ordering, ``` -------------------------------- ### Deprecated Cause Method for UnsupportedLumpVersion Source: https://docs.rs/vbsp/0.9.1/vbsp/error/struct.UnsupportedLumpVersion.html Deprecated method for getting the cause of the error. Use `Error::source` instead, which supports downcasting. ```rust fn cause(&self) -> Option<&dyn Error> ``` -------------------------------- ### Brush Implementations Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Brush.html Details the implementations for the Brush struct, including traits like BinRead, Clone, and Debug. ```APIDOC ### impl BinRead for Brush Provides methods for reading Brush data from a binary source. - `read_options`: Reads `Self` from the reader using the given `Endian` and arguments. - `read_be`: Reads `Self` from the reader using default arguments and assuming big-endian byte order. - `read_le`: Reads `Self` from the reader using default arguments and assuming little-endian byte order. - `read_ne`: Reads `T` from the reader assuming native-endian byte order. - `read_be_args`: Reads `Self` from the reader, assuming big-endian byte order, using the given arguments. - `read_le_args`: Reads `Self` from the reader, assuming little-endian byte order, using the given arguments. - `read_ne_args`: Reads `T` from the reader, assuming native-endian byte order, using the given arguments. ### impl Clone for Brush Provides methods for cloning Brush objects. - `clone`: Returns a duplicate of the value. - `clone_from`: Performs copy-assignment from `source`. ### impl Debug for Brush Provides a method for formatting the Brush struct for debugging purposes. - `fmt`: Formats the value using the given formatter. ``` -------------------------------- ### step_by() Method Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.EntitiesIter.html Creates a new iterator that yields elements from the original iterator, stepping by a specified amount. ```rust fn step_by(self, step: usize) -> StepBy where Self: Sized, ``` -------------------------------- ### Get Specific Property by Key Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.RawEntity.html Retrieves the string slice value for a given property key. Returns None if the key is not found. ```rust pub fn prop(&self, key: &'static str) -> Option<&'a str> ``` -------------------------------- ### impl Send for CompressedLightCube Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.CompressedLightCube.html Indicates that CompressedLightCube can be safely sent across threads. ```APIDOC ## Auto Trait Implementations ### impl Send for CompressedLightCube This implementation confirms that `CompressedLightCube` implements the `Send` trait, allowing instances of this type to be safely transferred between threads. ``` -------------------------------- ### Clone Implementation for PropPlacement Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.PropPlacement.html Allows creating a duplicate of a PropPlacement instance. This is useful for copying prop configurations. ```rust fn clone(&self) -> PropPlacement<'a> ``` -------------------------------- ### partition Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.EntitiesIter.html Consumes an iterator, creating two collections from it. ```APIDOC ## fn partition(self, f: F) -> (B, B) ### Description Consumes an iterator, creating two collections from it. ### Method `partition` ### Parameters #### Path Parameters - **f** (F) - Required - A closure that returns `true` for elements that should go into the first collection, and `false` for the second. ``` -------------------------------- ### Splitting a slice from the end Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Leaves.html Use `rsplit` to split a slice into subslices based on a predicate, starting from the end. The matched element is excluded. ```rust let slice = [11, 22, 33, 0, 44, 55]; let mut iter = slice.rsplit(|num| *num == 0); assert_eq!(iter.next().unwrap(), &[44, 55]); assert_eq!(iter.next().unwrap(), &[11, 22, 33]); assert_eq!(iter.next(), None); ``` -------------------------------- ### From and Into Trait Implementations Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.LightColor.html Provides standard conversions for `LightColor`. The `From` implementation allows creating `LightColor` from itself, and `Into` allows converting `LightColor` into other types that implement `From`. ```rust impl From for T Source #### fn from(t: T) -> T Returns the argument unchanged. Source ### impl Into for T where U: From, Source #### fn into(self) -> U Calls `U::from(self)`. That is, this conversion is whatever the implementation of `From for U` chooses to do. Source ``` -------------------------------- ### Get Subslice Range Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Leaves.html Finds the range of indices a subslice points to. Returns None if the subslice is not within the slice or not aligned. This API is nightly-only. ```rust #![feature(substr_range)] use core::range::Range; let nums = &[0, 5, 10, 0, 0, 5]; let mut iter = nums .split(|t| *t == 0) .map(|n| nums.subslice_range(n).unwrap()); assert_eq!(iter.next(), Some(Range { start: 0, end: 0 })); assert_eq!(iter.next(), Some(Range { start: 1, end: 3 })); assert_eq!(iter.next(), Some(Range { start: 4, end: 4 })); assert_eq!(iter.next(), Some(Range { start: 5, end: 6 })); ``` -------------------------------- ### Get Element or Subslice by Index Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Leaves.html Returns a reference to an element or subslice based on the index type. Handles out-of-bounds access by returning `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)); ``` -------------------------------- ### Octal Implementation Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.GameLumpFlags.html Allows formatting GameLumpFlags values in octal. ```APIDOC ### impl Octal for GameLumpFlags #### `fn fmt(&self, f: &mut Formatter<'_>) -> Result` Formats the value using the given formatter. ``` -------------------------------- ### From Trait Implementation Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Node.html Allows creating a Node from itself. ```APIDOC ## fn from(t: T) -> T ### Description Returns the argument unchanged. ### Method POST ### Endpoint N/A (SDK method) ### Parameters - **t** (T) - Required - The value to convert. ### Response #### Success Response (200) - **T** (T) - The original value. ``` -------------------------------- ### Get Last Element of Slice Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Leaves.html Returns the last element of the slice as an `Option<&T>`, or `None` if the slice is empty. Useful for peeking at the end of a collection. ```rust let v = [10, 40, 30]; assert_eq!(Some(&30), v.last()); let w: &[i32] = &[]; assert_eq!(None, w.last()); ``` -------------------------------- ### impl Unpin for CompressedLightCube Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.CompressedLightCube.html Indicates that CompressedLightCube does not require special handling for pinning. ```APIDOC ## Auto Trait Implementations ### impl Unpin for CompressedLightCube This implementation indicates that `CompressedLightCube` implements the `Unpin` trait. Types that are `Unpin` do not require special handling when used with asynchronous operations or other contexts that rely on pinning. ``` -------------------------------- ### Providing a Default Value with unwrap_or Source: https://docs.rs/vbsp/0.9.1/vbsp/type.BspResult.html Use `unwrap_or` to get the `Ok` value or a specified default if the Result is `Err`. Arguments are eagerly evaluated. ```rust let default = 2; let x: Result = Ok(9); assert_eq!(x.unwrap_or(default), 9); let x: Result = Err("error"); assert_eq!(x.unwrap_or(default), default); ``` -------------------------------- ### Get Visible Clusters for a Cluster Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.VisData.html Retrieves a BitVec representing visible clusters from a given cluster index. This method is part of the VisData implementation. ```rust pub fn visible_clusters(&self, cluster: i16) -> BitVec ``` -------------------------------- ### Provide Method for UnsupportedLumpVersion (Nightly Only) Source: https://docs.rs/vbsp/0.9.1/vbsp/error/struct.UnsupportedLumpVersion.html Experimental nightly-only API for providing type-based access to error context, intended for error reporting. ```rust fn provide<'a>(&'a self, request: &mut Request<'a>) ``` -------------------------------- ### Copy Implementation for LumpEntry Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.LumpEntry.html Indicates that LumpEntry instances can be copied directly. ```APIDOC ```rust impl Copy for LumpEntry ``` ``` -------------------------------- ### Get Underlying Bits Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.DisplacementTriangleFlags.html Retrieves the underlying `u8` representation of the flags. The returned value contains exactly the bits set in the flags value. ```rust pub const fn bits(&self) -> u8 ``` -------------------------------- ### as_rchunks Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Leaves.html 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`. ```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`. ### Panics Panics if `N` is zero. ### Examples ``` let slice = ['l', 'o', 'r', 'e', 'm']; let (remainder, chunks) = slice.as_rchunks(); assert_eq!(remainder, &['l']); assert_eq!(chunks, &[['o', 'r'], ['e', 'm']]); ``` ``` -------------------------------- ### Implement Clone for Model Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Model.html Enables creating a duplicate of a Model instance. Use `clone()` for a simple copy or `clone_from()` for in-place assignment. ```rust fn clone(&self) -> Model ``` ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### as_chunks Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Leaves.html Splits the slice into a slice of `N`-element arrays, starting at the beginning of the slice, and a remainder slice with length strictly less than `N`. ```APIDOC ## pub fn as_chunks(&self) -> (&[[T; N]], &[T]) ### Description Splits the slice into a slice of `N`-element arrays, starting at the beginning of the slice, and a remainder slice with length strictly less than `N`. The remainder is meaningful in the division sense. ### Parameters #### Path Parameters - **N** (const usize) - Required - The desired size of each chunk array. ### Panics Panics if `N` is zero. ### Examples ```rust let slice = ['l', 'o', 'r', 'e', 'm']; let (chunks, remainder) = slice.as_chunks(); assert_eq!(chunks, &[['l', 'o'], ['r', 'e']]); assert_eq!(remainder, &['m']); let slice = ['R', 'u', 's', 't']; let (chunks, []) = slice.as_chunks::<2>() else { panic!("slice didn't have even length") }; assert_eq!(chunks, &[['R', 'u'], ['s', 't']]); ``` ``` -------------------------------- ### BinRead Implementation for Directories Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Directories.html Provides methods for reading Directories from a binary source with various endianness and argument options. ```rust type Args<'__binrw_generated_args_lifetime> = () fn read_options( __binrw_generated_var_reader: &mut R, __binrw_generated_var_endian: Endian, __binrw_generated_var_arguments: Self::Args<'_>, ) -> BinResult fn read_be(reader: &mut R) -> Result where R: Read + Seek, Self::Args<'a>: for<'a> Required, fn read_le(reader: &mut R) -> Result where R: Read + Seek, Self::Args<'a>: for<'a> Required, fn read_ne(reader: &mut R) -> Result where R: Read + Seek, Self::Args<'a>: for<'a> Required, fn read_be_args(reader: &mut R, args: Self::Args<'_>) -> Result where R: Read + Seek, fn read_le_args(reader: &mut R, args: Self::Args<'_>) -> Result where R: Read + Seek, fn read_ne_args(reader: &mut R, args: Self::Args<'_>) -> Result where R: Read + Seek, ``` -------------------------------- ### Iterate Over Slice Elements Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Leaves.html Create an iterator over the slice elements using `iter`. The iterator yields references to each item from the start to the end of the slice. ```rust let x = &[1, 2, 4]; let mut iterator = x.iter(); assert_eq!(iterator.next(), Some(&1)); assert_eq!(iterator.next(), Some(&2)); assert_eq!(iterator.next(), Some(&4)); assert_eq!(iterator.next(), None); ``` -------------------------------- ### Clone Implementation for LightColor Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.LightColor.html Provides methods to duplicate a LightColor value. The `clone` method returns a new instance, while `clone_from` performs in-place assignment. ```rust impl Clone for LightColor Source #### fn clone(&self) -> LightColor Returns a duplicate of the value. Read more 1.0.0 (const: unstable) · Source #### fn clone_from(&mut self, source: &Self) Performs copy-assignment from `source`. Read more Source ``` -------------------------------- ### Unwrap or Default Value Source: https://docs.rs/vbsp/0.9.1/vbsp/type.BspResult.html Use `unwrap_or_default()` to get the contained `Ok` value or a default value if it's an `Err`. Requires the type to implement `Default`. ```rust let good_year_from_input = "1909"; let bad_year_from_input = "190blarg"; let good_year = good_year_from_input.parse().unwrap_or_default(); let bad_year = bad_year_from_input.parse().unwrap_or_default(); assert_eq!(1909, good_year); assert_eq!(0, bad_year); ``` -------------------------------- ### CloneToUninit Trait Implementations Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Leaf.html Provides an unsafe method for cloning data to an uninitialized memory location. This is a nightly-only experimental API. ```APIDOC ## unsafe fn clone_to_uninit(&self, dest: *mut u8) ### Description Performs copy-assignment from `self` to `dest`. ### Method `clone_to_uninit` ### Parameters - **dest** (*mut u8) - Required - A mutable pointer to the destination memory location. ### Response None ``` -------------------------------- ### rsplitn Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Leaves.html Returns an iterator over subslices separated by elements that match `pred` limited to returning at most `n` items. This starts at the end of the slice and works backwards. ```APIDOC ## rsplitn(&self, n: usize, pred: F) -> RSplitN<'_, T, F> ### Description Returns an iterator over subslices separated by elements that match `pred` limited to returning at most `n` items. This starts at the end of the slice and works backwards. The matched element is not contained in the subslices. The last element returned, if any, will contain the remainder of the slice. ### Parameters #### Path Parameters - **n** (usize) - Required - The maximum number of items to return. - **pred** (F) - Required - A closure that returns true for elements that should act as separators. ### Response Returns an iterator `RSplitN<'_, T, F>` over subslices. ``` -------------------------------- ### impl UnsafeUnpin for CompressedLightCube Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.CompressedLightCube.html Indicates that CompressedLightCube can be safely unpinned, even though it might involve unsafe operations. ```APIDOC ## Auto Trait Implementations ### impl UnsafeUnpin for CompressedLightCube This implementation signifies that `CompressedLightCube` implements `UnsafeUnpin`. This trait is a marker that indicates a type is `Unpin` even if its implementation relies on `unsafe` code. It allows the type to be pinned and unpinned safely. ``` -------------------------------- ### BinRead Implementation for GameLump Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.GameLump.html Provides methods for reading GameLump data from a binary source using the `binrw` crate. ```APIDOC ## impl BinRead for GameLump ### `read_options` Reads `Self` from the reader using the given `Endian` and arguments. ### `read_be` Reads `Self` from the reader using default arguments and assuming big-endian byte order. ### `read_le` Reads `Self` from the reader using default arguments and assuming little-endian byte order. ### `read_ne` Reads `T` from the reader assuming native-endian byte order. ### `read_be_args` Reads `Self` from the reader, assuming big-endian byte order, using the given arguments. ### `read_le_args` Reads `Self` from the reader, assuming little-endian byte order, using the given arguments. ### `read_ne_args` Reads `T` from the reader, assuming native-endian byte order, using the given arguments. ``` -------------------------------- ### rsplit Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Leaves.html Returns an iterator over subslices separated by elements that match `pred`, starting at the end of the slice and working backwards. The matched element is not contained in the subslices. ```APIDOC ## rsplit(&self, pred: F) -> RSplit<'_, T, F> ### Description Returns an iterator over subslices separated by elements that match `pred`, starting at the end of the slice and working backwards. The matched element is not contained in the subslices. ### Parameters #### Path Parameters - **pred** (F) - Required - A closure that returns true for elements that should act as separators. ### Response Returns an iterator `RSplit<'_, T, F>` over subslices. ``` -------------------------------- ### Brush Clone Implementation Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.Brush.html Provides methods for creating copies of a Brush instance. Includes `clone` for duplication and `clone_from` for assignment. ```rust fn clone(&self) -> Brush ``` ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### multipeek Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.EntitiesIter.html Creates an iterator adaptor that allows peeking at multiple next values without advancing the base iterator. ```APIDOC ## fn multipeek(self) -> MultiPeek ### Description An iterator adaptor that allows the user to peek at multiple `.next()` values without advancing the base iterator. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Method N/A (Method on Iterator trait) ### Endpoint N/A ### Request Example N/A ### Response #### Success Response - **MultiPeek** - An iterator adaptor for peeking. ``` -------------------------------- ### Undefined Behavior Example: Unchecked Unwrap on Err Source: https://docs.rs/vbsp/0.9.1/vbsp/type.BspResult.html Illustrates the undefined behavior that occurs when `unwrap_unchecked` is called on an `Err` variant. This code should not be run in production. ```rust let x: Result = Err("emergency failure"); unsafe { x.unwrap_unchecked() }; // Undefined behavior! ``` -------------------------------- ### TextureFlags Bit Manipulation: bits and from_bits Source: https://docs.rs/vbsp/0.9.1/vbsp/data/struct.TextureFlags.html Methods to get the underlying u32 representation of flags and to convert from a u32 value, handling potential unknown bits. ```rust pub const fn bits(&self) -> u32 ``` ```rust pub const fn from_bits(bits: u32) -> Option ``` -------------------------------- ### Display Implementation for UnsupportedLumpVersion Source: https://docs.rs/vbsp/0.9.1/vbsp/error/struct.UnsupportedLumpVersion.html Provides a human-readable string representation of the UnsupportedLumpVersion error. This is the recommended way to display the error. ```rust fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result ```