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

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

impl VkWrappedType<RawVkDebugReportFlags> for VkDebugReportFlags {
    fn vk_to_raw(src: &VkDebugReportFlags, dst: &mut RawVkDebugReportFlags) {
        *dst = 0;
        if src.information { *dst |= 0x00000001; }
        if src.warning { *dst |= 0x00000002; }
        if src.performance_warning { *dst |= 0x00000004; }
        if src.error { *dst |= 0x00000008; }
        if src.debug { *dst |= 0x00000010; }
    }
}

impl VkRawType<VkDebugReportFlags> for RawVkDebugReportFlags {
    fn vk_to_wrapped(src: &RawVkDebugReportFlags) -> VkDebugReportFlags {
        VkDebugReportFlags {
            information: (src & 0x00000001) != 0,
            warning: (src & 0x00000002) != 0,
            performance_warning: (src & 0x00000004) != 0,
            error: (src & 0x00000008) != 0,
            debug: (src & 0x00000010) != 0,
        }
    }
}

impl Default for VkDebugReportFlags {
    fn default() -> VkDebugReportFlags {
        VkDebugReportFlags {
            information: false,
            warning: false,
            performance_warning: false,
            error: false,
            debug: false,
        }
    }
}

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

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