inspect_core/
capability.rs1#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
8pub struct Capability {
9 bits: u32,
10}
11
12impl Capability {
13 pub const NONE: Self = Self { bits: 0 };
15
16 pub const INSPECT: Self = Self { bits: 1 << 0 };
18
19 pub const CHILDREN: Self = Self { bits: 1 << 1 };
21
22 pub const ACCESS: Self = Self { bits: 1 << 2 };
24
25 pub const READ_ALL: Self =
27 Self { bits: Self::INSPECT.bits | Self::CHILDREN.bits | Self::ACCESS.bits };
28
29 pub fn contains(self, other: Self) -> bool {
31 (self.bits & other.bits) == other.bits
32 }
33
34 pub fn union(self, other: Self) -> Self {
36 Self { bits: self.bits | other.bits }
37 }
38}
39
40impl Default for Capability {
41 fn default() -> Self {
42 Self::INSPECT
43 }
44}