| 1 | #![allow( |
| 2 | clippy::too_many_arguments, |
| 3 | clippy::cognitive_complexity, |
| 4 | clippy::wrong_self_convention, |
| 5 | unused_qualifications |
| 6 | )] |
| 7 | #[macro_use] |
| 8 | mod macros; |
| 9 | mod aliases; |
| 10 | pub use aliases::*; |
| 11 | mod bitflags; |
| 12 | pub use bitflags::*; |
| 13 | #[cfg(feature = "debug")] |
| 14 | mod const_debugs; |
| 15 | mod constants; |
| 16 | pub use constants::*; |
| 17 | mod definitions; |
| 18 | pub use definitions::*; |
| 19 | mod enums; |
| 20 | pub use enums::*; |
| 21 | mod extensions; |
| 22 | pub use extensions::*; |
| 23 | mod feature_extensions; |
| 24 | mod features; |
| 25 | pub use features::*; |
| 26 | mod prelude; |
| 27 | pub use prelude::*; |
| 28 | /// Native bindings from Vulkan headers, generated by bindgen |
| 29 | #[allow(clippy::useless_transmute, nonstandard_style)] |
| 30 | pub mod native; |
| 31 | mod platform_types; |
| 32 | pub use platform_types::*; |
| 33 | /// Iterates through the pointer chain. Includes the item that is passed into the function. |
| 34 | /// Stops at the last [`BaseOutStructure`] that has a null [`BaseOutStructure::p_next`] field. |
| 35 | pub(crate) unsafe fn ptr_chain_iter<T: ?Sized>( |
| 36 | ptr: &mut T, |
| 37 | ) -> impl Iterator<Item = *mut BaseOutStructure<'_>> { |
| 38 | let ptr = <*mut T>::cast::<BaseOutStructure<'_>>(ptr); |
| 39 | (0..).scan(ptr, |p_ptr, _| { |
| 40 | if p_ptr.is_null() { |
| 41 | return None; |
| 42 | } |
| 43 | let n_ptr = (**p_ptr).p_next; |
| 44 | let old = *p_ptr; |
| 45 | *p_ptr = n_ptr; |
| 46 | Some(old) |
| 47 | }) |
| 48 | } |
| 49 | pub trait Handle: Sized { |
| 50 | const TYPE: ObjectType; |
| 51 | fn as_raw(self) -> u64; |
| 52 | fn from_raw(_: u64) -> Self; |
| 53 | |
| 54 | /// Returns whether the handle is a `NULL` value. |
| 55 | /// |
| 56 | /// # Example |
| 57 | /// |
| 58 | /// ``` |
| 59 | /// # use ash::vk::{Handle, Instance}; |
| 60 | /// let instance = Instance::null(); |
| 61 | /// assert!(instance.is_null()); |
| 62 | /// ``` |
| 63 | fn is_null(self) -> bool { |
| 64 | self.as_raw() == 0 |
| 65 | } |
| 66 | } |