1use crate::serde_helpers::impl_bitfield_serde;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
13#[expect(
14 clippy::module_name_repetitions,
15 reason = "the type is going to be used outside this module"
16)]
17pub struct ParcelAccessFlags(pub u32);
18
19impl ParcelAccessFlags {
20 pub const NONE: Self = Self(0);
22 pub const ACCESS: Self = Self(1 << 0);
24 pub const BAN: Self = Self(1 << 1);
26 pub const ALLOW_EXPERIENCE: Self = Self(1 << 3);
28 pub const BLOCK_EXPERIENCE: Self = Self(1 << 4);
30
31 #[must_use]
33 pub const fn union(self, other: Self) -> Self {
34 Self(self.0 | other.0)
35 }
36
37 #[must_use]
39 pub const fn contains(self, other: Self) -> bool {
40 self.0 & other.0 == other.0
41 }
42
43 #[must_use]
45 pub const fn is_empty(self) -> bool {
46 self.0 == 0
47 }
48}
49
50impl_bitfield_serde!(
51 ParcelAccessFlags,
52 u32,
53 "ACCESS" => ParcelAccessFlags::ACCESS.0,
54 "BAN" => ParcelAccessFlags::BAN.0,
55 "ALLOW_EXPERIENCE" => ParcelAccessFlags::ALLOW_EXPERIENCE.0,
56 "BLOCK_EXPERIENCE" => ParcelAccessFlags::BLOCK_EXPERIENCE.0,
57);
58
59#[derive(Debug, Clone, Copy, PartialEq, Eq)]
63#[expect(
64 clippy::module_name_repetitions,
65 reason = "the type is going to be used outside this module"
66)]
67pub struct ParcelReturnType(pub u32);
68
69impl ParcelReturnType {
70 pub const NONE: Self = Self(1 << 0);
72 pub const OWNER: Self = Self(1 << 1);
74 pub const GROUP: Self = Self(1 << 2);
76 pub const OTHER: Self = Self(1 << 3);
78 pub const LIST: Self = Self(1 << 4);
80 pub const SELL: Self = Self(1 << 5);
82
83 #[must_use]
85 pub const fn union(self, other: Self) -> Self {
86 Self(self.0 | other.0)
87 }
88}
89
90impl_bitfield_serde!(
91 ParcelReturnType,
92 u32,
93 "NONE" => ParcelReturnType::NONE.0,
94 "OWNER" => ParcelReturnType::OWNER.0,
95 "GROUP" => ParcelReturnType::GROUP.0,
96 "OTHER" => ParcelReturnType::OTHER.0,
97 "LIST" => ParcelReturnType::LIST.0,
98 "SELL" => ParcelReturnType::SELL.0,
99);