mln-rs-engine 0.0.19

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 struct RenderPass(pub u8);

#[expect(non_upper_case_globals, reason = "the bit flags keep the C++ enumerator names")]
impl RenderPass {
    /// No pass.
    pub const None: RenderPass = RenderPass(0);
    /// The opaque pass, front to back.
    pub const Opaque: RenderPass = RenderPass(1 << 0);
    /// The translucent pass, back to front.
    pub const Translucent: RenderPass = RenderPass(1 << 1);

    /// The passes as their bits.
    #[must_use]
    pub 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)
    }
}