Skip to main content

jay_ash/
vk.rs

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