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

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

impl VkWrappedType<RawVkCommandPoolCreateFlags> for VkCommandPoolCreateFlags {
    fn vk_to_raw(src: &VkCommandPoolCreateFlags, dst: &mut RawVkCommandPoolCreateFlags) {
        *dst = 0;
        if src.transient { *dst |= 0x00000001; }
        if src.reset_command_buffer { *dst |= 0x00000002; }
        if src.protected { *dst |= 0x00000004; }
    }
}

impl VkRawType<VkCommandPoolCreateFlags> for RawVkCommandPoolCreateFlags {
    fn vk_to_wrapped(src: &RawVkCommandPoolCreateFlags) -> VkCommandPoolCreateFlags {
        VkCommandPoolCreateFlags {
            transient: (src & 0x00000001) != 0,
            reset_command_buffer: (src & 0x00000002) != 0,
            protected: (src & 0x00000004) != 0,
        }
    }
}

impl Default for VkCommandPoolCreateFlags {
    fn default() -> VkCommandPoolCreateFlags {
        VkCommandPoolCreateFlags {
            transient: false,
            reset_command_buffer: false,
            protected: false,
        }
    }
}

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

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