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

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

impl VkWrappedType<RawVkCompositeAlphaFlags> for VkCompositeAlphaFlags {
    fn vk_to_raw(src: &VkCompositeAlphaFlags, dst: &mut RawVkCompositeAlphaFlags) {
        *dst = 0;
        if src.opaque { *dst |= 0x00000001; }
        if src.pre_multiplied { *dst |= 0x00000002; }
        if src.post_multiplied { *dst |= 0x00000004; }
        if src.inherit { *dst |= 0x00000008; }
    }
}

impl VkRawType<VkCompositeAlphaFlags> for RawVkCompositeAlphaFlags {
    fn vk_to_wrapped(src: &RawVkCompositeAlphaFlags) -> VkCompositeAlphaFlags {
        VkCompositeAlphaFlags {
            opaque: (src & 0x00000001) != 0,
            pre_multiplied: (src & 0x00000002) != 0,
            post_multiplied: (src & 0x00000004) != 0,
            inherit: (src & 0x00000008) != 0,
        }
    }
}

impl Default for VkCompositeAlphaFlags {
    fn default() -> VkCompositeAlphaFlags {
        VkCompositeAlphaFlags {
            opaque: false,
            pre_multiplied: false,
            post_multiplied: false,
            inherit: false,
        }
    }
}

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

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