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

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

impl VkWrappedType<RawVkMemoryAllocateFlags> for VkMemoryAllocateFlags {
    fn vk_to_raw(src: &VkMemoryAllocateFlags, dst: &mut RawVkMemoryAllocateFlags) {
        *dst = 0;
        if src.device_mask { *dst |= 0x00000001; }
        if src.device_address { *dst |= 0x00000002; }
        if src.device_address_capture_replay { *dst |= 0x00000004; }
    }
}

impl VkRawType<VkMemoryAllocateFlags> for RawVkMemoryAllocateFlags {
    fn vk_to_wrapped(src: &RawVkMemoryAllocateFlags) -> VkMemoryAllocateFlags {
        VkMemoryAllocateFlags {
            device_mask: (src & 0x00000001) != 0,
            device_address: (src & 0x00000002) != 0,
            device_address_capture_replay: (src & 0x00000004) != 0,
        }
    }
}

impl Default for VkMemoryAllocateFlags {
    fn default() -> VkMemoryAllocateFlags {
        VkMemoryAllocateFlags {
            device_mask: false,
            device_address: false,
            device_address_capture_replay: false,
        }
    }
}

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

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