mln-rs-engine 0.0.18

Part of mln-rs, a Rust port of the MapLibre Native map rendering core. Depend on mln-rs instead.
Documentation
use std::ops::{BitAnd, BitOr, BitOrAssign};

/// The render passes a layer draws in. A bitmask (`Opaque | Translucent` is a
/// valid value), so a newtype rather than a Rust enum. The associated constants
/// keep the C++ enumerator names.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub(crate) struct RenderPass(pub(crate) u8);

#[expect(non_upper_case_globals, reason = "the bit flags keep the C++ enumerator names")]
impl RenderPass {
    pub(crate) const None: RenderPass = RenderPass(0);
    pub(crate) const Opaque: RenderPass = RenderPass(1 << 0);
    pub(crate) const Translucent: RenderPass = RenderPass(1 << 1);
    pub(crate) const Pass3D: RenderPass = RenderPass(1 << 2);

    #[must_use]
    pub(crate) fn underlying_type(self) -> u8 {
        self.0
    }
}

impl BitOr for RenderPass {
    type Output = RenderPass;
    fn bitor(self, rhs: RenderPass) -> RenderPass {
        RenderPass(self.0 | rhs.0)
    }
}

impl BitOrAssign for RenderPass {
    fn bitor_assign(&mut self, rhs: RenderPass) {
        self.0 |= rhs.0;
    }
}

impl BitAnd for RenderPass {
    type Output = RenderPass;
    fn bitand(self, rhs: RenderPass) -> RenderPass {
        RenderPass(self.0 & rhs.0)
    }
}