sl_types/parcel.rs
1//! Parcel value types: access-list flags and object-return classifications.
2
3/// The per-entry classification flags on a parcel access (allow) or ban list.
4///
5/// A bitfield carried by every entry of a parcel access-list reply (alongside
6/// the whole-list scope). On Second Life an entry can be flagged as an
7/// experience allow/block in addition to the plain access/ban list it belongs
8/// to; OpenSim sets the per-entry flags equal to the list's scope. Combine the
9/// constants with [`ParcelAccessFlags::union`].
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
11#[expect(
12 clippy::module_name_repetitions,
13 reason = "the type is going to be used outside this module"
14)]
15pub struct ParcelAccessFlags(pub u32);
16
17impl ParcelAccessFlags {
18 /// No flags set.
19 pub const NONE: Self = Self(0);
20 /// The entry is on the access (allow) list (`AL_ACCESS`, `1 << 0`).
21 pub const ACCESS: Self = Self(1 << 0);
22 /// The entry is on the ban list (`AL_BAN`, `1 << 1`).
23 pub const BAN: Self = Self(1 << 1);
24 /// The entry allows an experience (`AL_ALLOW_EXPERIENCE`, `1 << 3`).
25 pub const ALLOW_EXPERIENCE: Self = Self(1 << 3);
26 /// The entry blocks an experience (`AL_BLOCK_EXPERIENCE`, `1 << 4`).
27 pub const BLOCK_EXPERIENCE: Self = Self(1 << 4);
28
29 /// Combines two sets of access flags.
30 #[must_use]
31 pub const fn union(self, other: Self) -> Self {
32 Self(self.0 | other.0)
33 }
34
35 /// Whether every bit of `other` is set in `self`.
36 #[must_use]
37 pub const fn contains(self, other: Self) -> bool {
38 self.0 & other.0 == other.0
39 }
40
41 /// Whether no flags are set.
42 #[must_use]
43 pub const fn is_empty(self) -> bool {
44 self.0 == 0
45 }
46}
47
48/// The kinds of objects to return or select on a parcel, as the `ReturnType` of
49/// a parcel object-return or object-select request. A bitfield: combine the
50/// constants with [`ParcelReturnType::union`].
51#[derive(Debug, Clone, Copy, PartialEq, Eq)]
52#[expect(
53 clippy::module_name_repetitions,
54 reason = "the type is going to be used outside this module"
55)]
56pub struct ParcelReturnType(pub u32);
57
58impl ParcelReturnType {
59 /// No objects (`RT_NONE`).
60 pub const NONE: Self = Self(1 << 0);
61 /// Objects owned by the parcel's owner (`RT_OWNER`).
62 pub const OWNER: Self = Self(1 << 1);
63 /// Objects set to the parcel's group (`RT_GROUP`).
64 pub const GROUP: Self = Self(1 << 2);
65 /// Objects owned by anyone else (`RT_OTHER`).
66 pub const OTHER: Self = Self(1 << 3);
67 /// Only the objects in the supplied id list (`RT_LIST`).
68 pub const LIST: Self = Self(1 << 4);
69 /// Objects that are for sale (`RT_SELL`).
70 pub const SELL: Self = Self(1 << 5);
71
72 /// Combines two sets of return-type bits.
73 #[must_use]
74 pub const fn union(self, other: Self) -> Self {
75 Self(self.0 | other.0)
76 }
77}