sl_types/friend.rs
1//! Friendship-related value types.
2
3/// The rights one party grants the other in a Second Life friendship: a
4/// bitfield shared by the login `buddy-list`, `GrantUserRights`, and
5/// `ChangeUserRights`. The flag values match the viewer's `RIGHTS_*`/`GRANT_*`
6/// constants.
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
8#[expect(
9 clippy::module_name_repetitions,
10 reason = "the type is going to be used outside this module"
11)]
12pub struct FriendRights(pub i32);
13
14impl FriendRights {
15 /// The other party may see when this party is online (`GRANT_ONLINE_STATUS`).
16 pub const CAN_SEE_ONLINE: i32 = 1 << 0;
17 /// The other party may see this party's location on the world map
18 /// (`GRANT_MAP_LOCATION`).
19 pub const CAN_SEE_ON_MAP: i32 = 1 << 1;
20 /// The other party may modify this party's objects (`GRANT_MODIFY_OBJECTS`).
21 pub const CAN_MODIFY_OBJECTS: i32 = 1 << 2;
22
23 /// Whether the see-online bit is set.
24 #[must_use]
25 pub const fn can_see_online(self) -> bool {
26 self.0 & Self::CAN_SEE_ONLINE != 0
27 }
28
29 /// Whether the see-on-map bit is set.
30 #[must_use]
31 pub const fn can_see_on_map(self) -> bool {
32 self.0 & Self::CAN_SEE_ON_MAP != 0
33 }
34
35 /// Whether the modify-objects bit is set.
36 #[must_use]
37 pub const fn can_modify_objects(self) -> bool {
38 self.0 & Self::CAN_MODIFY_OBJECTS != 0
39 }
40}