lava 0.4.9

Rust wrapper to manipulate Vulkan more conveniently than with bindings.
Documentation
// Generated by `scripts/generate.js`

use utils::vk_traits::*;

/// Wrapper for [VkDescriptorPoolCreateFlags](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkDescriptorPoolCreateFlags.html).
///
/// Use the macro `VkDescriptorPoolCreateFlags!` as an alternative method to create a structure. For example, these two snippets return the same value:
/// ```
/// VkDescriptorPoolCreateFlags!(free_descriptor_set, update_after_bind)
/// ```
/// ```
/// VkDescriptorPoolCreateFlags {
///     free_descriptor_set: true,
///     update_after_bind: true,
/// }
/// ```
#[derive(Debug, Clone)]
pub struct VkDescriptorPoolCreateFlags {
    pub free_descriptor_set: bool,
    pub update_after_bind: bool,
}

#[doc(hidden)]
pub type RawVkDescriptorPoolCreateFlags = u32;

impl VkWrappedType<RawVkDescriptorPoolCreateFlags> for VkDescriptorPoolCreateFlags {
    fn vk_to_raw(src: &VkDescriptorPoolCreateFlags, dst: &mut RawVkDescriptorPoolCreateFlags) {
        *dst = 0;
        if src.free_descriptor_set { *dst |= 0x00000001; }
        if src.update_after_bind { *dst |= 0x00000002; }
    }
}

impl VkRawType<VkDescriptorPoolCreateFlags> for RawVkDescriptorPoolCreateFlags {
    fn vk_to_wrapped(src: &RawVkDescriptorPoolCreateFlags) -> VkDescriptorPoolCreateFlags {
        VkDescriptorPoolCreateFlags {
            free_descriptor_set: (src & 0x00000001) != 0,
            update_after_bind: (src & 0x00000002) != 0,
        }
    }
}

impl Default for VkDescriptorPoolCreateFlags {
    fn default() -> VkDescriptorPoolCreateFlags {
        VkDescriptorPoolCreateFlags {
            free_descriptor_set: false,
            update_after_bind: false,
        }
    }
}

impl VkDescriptorPoolCreateFlags {
    
    /// Return a structure with all flags to `false`.
    pub fn none() -> Self {
        VkDescriptorPoolCreateFlags {
            free_descriptor_set: false,
            update_after_bind: false,
        }
    }
    
    /// Return a structure with all flags to `true`.
    pub fn all() -> Self {
        VkDescriptorPoolCreateFlags {
            free_descriptor_set: true,
            update_after_bind: true,
        }
    }
    
    /// Return the numerical bit flags corresponding to the structure (as described in the Vulkan specs).
    pub fn to_u32(&self) -> u32 {
        0
        + if self.free_descriptor_set { 0x00000001 } else { 0 }
        + if self.update_after_bind { 0x00000002 } else { 0 }
    }
    
    /// Create a structure corresponding to the specified numerical bit flags.
    pub fn from_u32(value: u32) -> Self {
        VkDescriptorPoolCreateFlags {
            free_descriptor_set: value & 0x00000001 > 0,
            update_after_bind: value & 0x00000002 > 0,
        }
    }
}

#[doc(hidden)]
#[macro_export]
macro_rules! VkDescriptorPoolCreateFlags {
    ( $( $x:ident ),* ) => {
        VkDescriptorPoolCreateFlags {
            $($x: true,)*
            ..VkDescriptorPoolCreateFlags::none()
        }
    }
}