1use crate::serde_helpers::impl_bitfield_serde;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
10#[expect(
11 clippy::module_name_repetitions,
12 reason = "the type is going to be used outside this module"
13)]
14pub struct FriendRights(pub i32);
15
16impl FriendRights {
17 pub const CAN_SEE_ONLINE: i32 = 1 << 0;
19 pub const CAN_SEE_ON_MAP: i32 = 1 << 1;
22 pub const CAN_MODIFY_OBJECTS: i32 = 1 << 2;
24
25 #[must_use]
27 pub const fn can_see_online(self) -> bool {
28 self.0 & Self::CAN_SEE_ONLINE != 0
29 }
30
31 #[must_use]
33 pub const fn can_see_on_map(self) -> bool {
34 self.0 & Self::CAN_SEE_ON_MAP != 0
35 }
36
37 #[must_use]
39 pub const fn can_modify_objects(self) -> bool {
40 self.0 & Self::CAN_MODIFY_OBJECTS != 0
41 }
42}
43
44impl_bitfield_serde!(
45 FriendRights,
46 i32,
47 "CAN_SEE_ONLINE" => FriendRights::CAN_SEE_ONLINE,
48 "CAN_SEE_ON_MAP" => FriendRights::CAN_SEE_ON_MAP,
49 "CAN_MODIFY_OBJECTS" => FriendRights::CAN_MODIFY_OBJECTS,
50);