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

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

impl VkWrappedType<RawVkStencilFaceFlags> for VkStencilFaceFlags {
    fn vk_to_raw(src: &VkStencilFaceFlags, dst: &mut RawVkStencilFaceFlags) {
        *dst = 0;
        if src.front { *dst |= 0x00000001; }
        if src.back { *dst |= 0x00000002; }
        if src.front_and_back { *dst |= 0x00000003; }
    }
}

impl VkRawType<VkStencilFaceFlags> for RawVkStencilFaceFlags {
    fn vk_to_wrapped(src: &RawVkStencilFaceFlags) -> VkStencilFaceFlags {
        VkStencilFaceFlags {
            front: (src & 0x00000001) != 0,
            back: (src & 0x00000002) != 0,
            front_and_back: (src & 0x00000003) != 0,
        }
    }
}

impl Default for VkStencilFaceFlags {
    fn default() -> VkStencilFaceFlags {
        VkStencilFaceFlags {
            front: false,
            back: false,
            front_and_back: false,
        }
    }
}

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

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