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 [VkSubpassDescriptionFlags](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkSubpassDescriptionFlags.html).
///
/// Use the macro `VkSubpassDescriptionFlags!` as an alternative method to create a structure. For example, these two snippets return the same value:
/// ```
/// VkSubpassDescriptionFlags!(per_view_attributes_nvx, per_view_position_x_only_nvx)
/// ```
/// ```
/// VkSubpassDescriptionFlags {
///     per_view_attributes_nvx: true,
///     per_view_position_x_only_nvx: true,
/// }
/// ```
#[derive(Debug, Clone)]
pub struct VkSubpassDescriptionFlags {
    pub per_view_attributes_nvx: bool,
    pub per_view_position_x_only_nvx: bool,
}

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

impl VkWrappedType<RawVkSubpassDescriptionFlags> for VkSubpassDescriptionFlags {
    fn vk_to_raw(src: &VkSubpassDescriptionFlags, dst: &mut RawVkSubpassDescriptionFlags) {
        *dst = 0;
        if src.per_view_attributes_nvx { *dst |= 0x00000001; }
        if src.per_view_position_x_only_nvx { *dst |= 0x00000002; }
    }
}

impl VkRawType<VkSubpassDescriptionFlags> for RawVkSubpassDescriptionFlags {
    fn vk_to_wrapped(src: &RawVkSubpassDescriptionFlags) -> VkSubpassDescriptionFlags {
        VkSubpassDescriptionFlags {
            per_view_attributes_nvx: (src & 0x00000001) != 0,
            per_view_position_x_only_nvx: (src & 0x00000002) != 0,
        }
    }
}

impl Default for VkSubpassDescriptionFlags {
    fn default() -> VkSubpassDescriptionFlags {
        VkSubpassDescriptionFlags {
            per_view_attributes_nvx: false,
            per_view_position_x_only_nvx: false,
        }
    }
}

impl VkSubpassDescriptionFlags {
    
    /// Return a structure with all flags to `false`.
    pub fn none() -> Self {
        VkSubpassDescriptionFlags {
            per_view_attributes_nvx: false,
            per_view_position_x_only_nvx: false,
        }
    }
    
    /// Return a structure with all flags to `true`.
    pub fn all() -> Self {
        VkSubpassDescriptionFlags {
            per_view_attributes_nvx: true,
            per_view_position_x_only_nvx: 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.per_view_attributes_nvx { 0x00000001 } else { 0 }
        + if self.per_view_position_x_only_nvx { 0x00000002 } else { 0 }
    }
    
    /// Create a structure corresponding to the specified numerical bit flags.
    pub fn from_u32(value: u32) -> Self {
        VkSubpassDescriptionFlags {
            per_view_attributes_nvx: value & 0x00000001 > 0,
            per_view_position_x_only_nvx: value & 0x00000002 > 0,
        }
    }
}

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