@@ -36,6 +36,11 @@ pub enum EncryptionState {
36
36
/// The room is encrypted.
37
37
Encrypted ,
38
38
39
+ /// The room is encrypted, additionally requiring state events to be
40
+ /// encrypted.
41
+ #[ cfg( feature = "experimental-encrypted-state-events" ) ]
42
+ StateEncrypted ,
43
+
39
44
/// The room is not encrypted.
40
45
NotEncrypted ,
41
46
@@ -46,10 +51,25 @@ pub enum EncryptionState {
46
51
47
52
impl EncryptionState {
48
53
/// Check whether `EncryptionState` is [`Encrypted`][Self::Encrypted].
54
+ #[ cfg( not( feature = "experimental-encrypted-state-events" ) ) ]
49
55
pub fn is_encrypted ( & self ) -> bool {
50
56
matches ! ( self , Self :: Encrypted )
51
57
}
52
58
59
+ /// Check whether `EncryptionState` is [`Encrypted`][Self::Encrypted] or
60
+ /// [`StateEncrypted`][Self::StateEncrypted].
61
+ #[ cfg( feature = "experimental-encrypted-state-events" ) ]
62
+ pub fn is_encrypted ( & self ) -> bool {
63
+ matches ! ( self , Self :: Encrypted | Self :: StateEncrypted )
64
+ }
65
+
66
+ /// Check whether `EncryptionState` is
67
+ /// [`StateEncrypted`][Self::StateEncrypted].
68
+ #[ cfg( feature = "experimental-encrypted-state-events" ) ]
69
+ pub fn is_state_encrypted ( & self ) -> bool {
70
+ matches ! ( self , Self :: StateEncrypted )
71
+ }
72
+
53
73
/// Check whether `EncryptionState` is [`Unknown`][Self::Unknown].
54
74
pub fn is_unknown ( & self ) -> bool {
55
75
matches ! ( self , Self :: Unknown )
@@ -155,5 +175,16 @@ mod tests {
155
175
assert ! ( EncryptionState :: Unknown . is_encrypted( ) . not( ) ) ;
156
176
assert ! ( EncryptionState :: Encrypted . is_encrypted( ) ) ;
157
177
assert ! ( EncryptionState :: NotEncrypted . is_encrypted( ) . not( ) ) ;
178
+
179
+ #[ cfg( feature = "experimental-encrypted-state-events" ) ]
180
+ {
181
+ assert ! ( EncryptionState :: StateEncrypted . is_unknown( ) . not( ) ) ;
182
+ assert ! ( EncryptionState :: StateEncrypted . is_encrypted( ) ) ;
183
+
184
+ assert ! ( EncryptionState :: Unknown . is_state_encrypted( ) . not( ) ) ;
185
+ assert ! ( EncryptionState :: Encrypted . is_state_encrypted( ) . not( ) ) ;
186
+ assert ! ( EncryptionState :: StateEncrypted . is_state_encrypted( ) ) ;
187
+ assert ! ( EncryptionState :: NotEncrypted . is_state_encrypted( ) . not( ) ) ;
188
+ }
158
189
}
159
190
}
0 commit comments