+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub struct SessionFlags(pub u16);
+
+impl SessionFlags {
+ pub const NONE: Self = Self(0);
+
+ pub const ENCRYPT_CONTENT: Self = Self(0x0001);
+ pub const ENCRYPT_NAME: Self = Self(0x0002);
+ pub const ENCRYPT_PROPERTIES: Self = Self(0x0004);
+
+ pub const DECRYPT_CONTENT: Self = Self(0x0008);
+ pub const DECRYPT_NAME: Self = Self(0x0010);
+ pub const DECRYPT_PROPERTIES: Self = Self(0x0020);
+
+ pub const STORE_HASH: Self = Self(0x0040);
+
+ pub const CONTENT_CRYPTO: Self =
+ Self(Self::ENCRYPT_CONTENT.0 | Self::DECRYPT_CONTENT.0);
+
+ pub const FULL_CRYPTO: Self =
+ Self(
+ Self::ENCRYPT_CONTENT.0
+ | Self::ENCRYPT_NAME.0
+ | Self::ENCRYPT_PROPERTIES.0
+ | Self::DECRYPT_CONTENT.0
+ | Self::DECRYPT_NAME.0
+ | Self::DECRYPT_PROPERTIES.0,
+ );
+
+ pub const fn contains(self, other: Self) -> bool {
+ (self.0 & other.0) == other.0
+ }
+
+ pub const fn intersects(self, other: Self) -> bool {
+ (self.0 & other.0) != 0
+ }
+
+ pub const fn bits(self) -> u16 {
+ self.0
+ }
+}
+
+impl BitOr for SessionFlags {
+ type Output = Self;
+
+ fn bitor(self, rhs: Self) -> Self {
+ Self(self.0 | rhs.0)
+ }
+}
+
+impl BitOrAssign for SessionFlags {
+ fn bitor_assign(&mut self, rhs: Self) {
+ self.0 |= rhs.0;
+ }
+}
+
+impl BitAnd for SessionFlags {
+ type Output = Self;
+
+ fn bitand(self, rhs: Self) -> Self {
+ Self(self.0 & rhs.0)
+ }
+}
+
+impl BitAndAssign for SessionFlags {
+ fn bitand_assign(&mut self, rhs: Self) {
+ self.0 &= rhs.0;
+ }
+}
+