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

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

impl VkWrappedType<RawVkGeometryFlags> for VkGeometryFlags {
    fn vk_to_raw(src: &VkGeometryFlags, dst: &mut RawVkGeometryFlags) {
        *dst = 0;
        if src.opaque { *dst |= 0x00000001; }
        if src.no_duplicate_any_hit_invocation { *dst |= 0x00000002; }
    }
}

impl VkRawType<VkGeometryFlags> for RawVkGeometryFlags {
    fn vk_to_wrapped(src: &RawVkGeometryFlags) -> VkGeometryFlags {
        VkGeometryFlags {
            opaque: (src & 0x00000001) != 0,
            no_duplicate_any_hit_invocation: (src & 0x00000002) != 0,
        }
    }
}

impl Default for VkGeometryFlags {
    fn default() -> VkGeometryFlags {
        VkGeometryFlags {
            opaque: false,
            no_duplicate_any_hit_invocation: false,
        }
    }
}

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

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