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    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}
49pub 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}