Skip to main content

metal_options

Macro metal_options 

Source
macro_rules! metal_options {
    (
        $(#[$meta:meta])*
        $vis:vis struct $name:ident : $repr:ty {
            $(
                $(#[$flag_meta:meta])*
                const $flag:ident = $value:expr;
            )*
        }
    ) => { ... };
}
Expand description

Define a Metal options/bitflags type.

Creates a newtype wrapper around a primitive integer type with bitwise operations and associated constants for each flag.

§Examples

metal_options! {
    /// Resource storage and caching options.
    pub struct ResourceOptions: u64 {
        const CPU_CACHE_MODE_DEFAULT = 0;
        const CPU_CACHE_MODE_WRITE_COMBINED = 1 << 0;
        const STORAGE_MODE_SHARED = 0 << 4;
        const STORAGE_MODE_MANAGED = 1 << 4;
        const STORAGE_MODE_PRIVATE = 2 << 4;
    }
}

let opts = ResourceOptions::STORAGE_MODE_PRIVATE | ResourceOptions::CPU_CACHE_MODE_WRITE_COMBINED;