Skip to main content

sl_types/
experience.rs

1//! Experience value types: the property bitfield carried in experience info.
2
3/// Experience [`properties`](ExperienceProperties) bit: the experience id is
4/// invalid (a placeholder for an `error_ids` entry the grid could not resolve).
5pub const PROPERTY_INVALID: i32 = 1 << 0;
6/// Experience properties bit: privileged (a Linden-blessed experience).
7pub const PROPERTY_PRIVILEGED: i32 = 1 << 3;
8/// Experience properties bit: grid-wide scope (vs. land-scoped). Mirrors the
9/// viewer's grid-scope notification on a permission request.
10pub const PROPERTY_GRID: i32 = 1 << 4;
11/// Experience properties bit: the experience is private.
12pub const PROPERTY_PRIVATE: i32 = 1 << 5;
13/// Experience properties bit: the experience is disabled.
14pub const PROPERTY_DISABLED: i32 = 1 << 6;
15/// Experience properties bit: the experience is suspended by an admin.
16pub const PROPERTY_SUSPENDED: i32 = 1 << 7;
17
18/// The bitfield of experience-info property flags (the `PROPERTY_*` constants).
19/// Mirrors the viewer's `LLExperienceCache` property bits, which it notes should
20/// track the grid's `experience-api` model.
21#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
22#[expect(
23    clippy::module_name_repetitions,
24    reason = "the type is going to be used outside this module"
25)]
26pub struct ExperienceProperties(pub i32);
27
28impl ExperienceProperties {
29    /// Whether all of the bits in `flag` are set.
30    #[must_use]
31    pub const fn contains(self, flag: i32) -> bool {
32        self.0 & flag == flag
33    }
34
35    /// Whether the experience id is invalid ([`PROPERTY_INVALID`]).
36    #[must_use]
37    pub const fn is_invalid(self) -> bool {
38        self.contains(PROPERTY_INVALID)
39    }
40
41    /// Whether the experience is privileged ([`PROPERTY_PRIVILEGED`]).
42    #[must_use]
43    pub const fn is_privileged(self) -> bool {
44        self.contains(PROPERTY_PRIVILEGED)
45    }
46
47    /// Whether the experience is grid-wide ([`PROPERTY_GRID`]); otherwise it is
48    /// land-scoped.
49    #[must_use]
50    pub const fn is_grid(self) -> bool {
51        self.contains(PROPERTY_GRID)
52    }
53
54    /// Whether the experience is private ([`PROPERTY_PRIVATE`]).
55    #[must_use]
56    pub const fn is_private(self) -> bool {
57        self.contains(PROPERTY_PRIVATE)
58    }
59
60    /// Whether the experience is disabled ([`PROPERTY_DISABLED`]).
61    #[must_use]
62    pub const fn is_disabled(self) -> bool {
63        self.contains(PROPERTY_DISABLED)
64    }
65
66    /// Whether the experience is suspended ([`PROPERTY_SUSPENDED`]).
67    #[must_use]
68    pub const fn is_suspended(self) -> bool {
69        self.contains(PROPERTY_SUSPENDED)
70    }
71}