use crate::serde_helpers::impl_bitfield_serde;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[expect(
clippy::module_name_repetitions,
reason = "the type is going to be used outside this module"
)]
pub struct ParcelAccessFlags(pub u32);
impl ParcelAccessFlags {
pub const NONE: Self = Self(0);
pub const ACCESS: Self = Self(1 << 0);
pub const BAN: Self = Self(1 << 1);
pub const ALLOW_EXPERIENCE: Self = Self(1 << 3);
pub const BLOCK_EXPERIENCE: Self = Self(1 << 4);
#[must_use]
pub const fn union(self, other: Self) -> Self {
Self(self.0 | other.0)
}
#[must_use]
pub const fn contains(self, other: Self) -> bool {
self.0 & other.0 == other.0
}
#[must_use]
pub const fn is_empty(self) -> bool {
self.0 == 0
}
}
impl_bitfield_serde!(
ParcelAccessFlags,
u32,
"ACCESS" => ParcelAccessFlags::ACCESS.0,
"BAN" => ParcelAccessFlags::BAN.0,
"ALLOW_EXPERIENCE" => ParcelAccessFlags::ALLOW_EXPERIENCE.0,
"BLOCK_EXPERIENCE" => ParcelAccessFlags::BLOCK_EXPERIENCE.0,
);
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[expect(
clippy::module_name_repetitions,
reason = "the type is going to be used outside this module"
)]
pub struct ParcelReturnType(pub u32);
impl ParcelReturnType {
pub const NONE: Self = Self(1 << 0);
pub const OWNER: Self = Self(1 << 1);
pub const GROUP: Self = Self(1 << 2);
pub const OTHER: Self = Self(1 << 3);
pub const LIST: Self = Self(1 << 4);
pub const SELL: Self = Self(1 << 5);
#[must_use]
pub const fn union(self, other: Self) -> Self {
Self(self.0 | other.0)
}
}
impl_bitfield_serde!(
ParcelReturnType,
u32,
"NONE" => ParcelReturnType::NONE.0,
"OWNER" => ParcelReturnType::OWNER.0,
"GROUP" => ParcelReturnType::GROUP.0,
"OTHER" => ParcelReturnType::OTHER.0,
"LIST" => ParcelReturnType::LIST.0,
"SELL" => ParcelReturnType::SELL.0,
);