1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#[cfg(feature = "qrcode")]
mod qrcode;
mod requests;
mod sas;
pub use matrix_sdk_base::crypto::{format_emojis, AcceptSettings, CancelInfo, Emoji};
#[cfg(feature = "qrcode")]
pub use matrix_sdk_base::crypto::{
matrix_sdk_qrcode::{DecodingError, EncodingError, QrVerificationData},
ScanError,
};
#[cfg(feature = "qrcode")]
pub use qrcode::QrVerification;
pub use requests::VerificationRequest;
pub use sas::SasVerification;
#[derive(Debug, Clone)]
pub enum Verification {
SasV1(SasVerification),
#[cfg(feature = "qrcode")]
QrV1(QrVerification),
}
impl Verification {
pub fn sas(self) -> Option<SasVerification> {
#[allow(irrefutable_let_patterns)]
if let Verification::SasV1(sas) = self {
Some(sas)
} else {
None
}
}
#[cfg(feature = "qrcode")]
pub fn qr(self) -> Option<QrVerification> {
if let Verification::QrV1(qr) = self {
Some(qr)
} else {
None
}
}
pub fn is_done(&self) -> bool {
match self {
Verification::SasV1(s) => s.is_done(),
#[cfg(feature = "qrcode")]
Verification::QrV1(qr) => qr.is_done(),
}
}
pub fn is_cancelled(&self) -> bool {
match self {
Verification::SasV1(s) => s.is_cancelled(),
#[cfg(feature = "qrcode")]
Verification::QrV1(qr) => qr.is_cancelled(),
}
}
pub fn cancel_info(&self) -> Option<CancelInfo> {
match self {
Verification::SasV1(s) => s.cancel_info(),
#[cfg(feature = "qrcode")]
Verification::QrV1(q) => q.cancel_info(),
}
}
pub fn own_user_id(&self) -> &ruma::UserId {
match self {
Verification::SasV1(v) => v.own_user_id(),
#[cfg(feature = "qrcode")]
Verification::QrV1(v) => v.own_user_id(),
}
}
pub fn other_user_id(&self) -> &ruma::UserId {
match self {
Verification::SasV1(v) => v.inner.other_user_id(),
#[cfg(feature = "qrcode")]
Verification::QrV1(v) => v.inner.other_user_id(),
}
}
pub fn is_self_verification(&self) -> bool {
match self {
Verification::SasV1(v) => v.is_self_verification(),
#[cfg(feature = "qrcode")]
Verification::QrV1(v) => v.is_self_verification(),
}
}
pub fn we_started(&self) -> bool {
match self {
Verification::SasV1(s) => s.we_started(),
#[cfg(feature = "qrcode")]
Verification::QrV1(q) => q.we_started(),
}
}
}
impl From<SasVerification> for Verification {
fn from(sas: SasVerification) -> Self {
Self::SasV1(sas)
}
}
#[cfg(feature = "qrcode")]
impl From<QrVerification> for Verification {
fn from(qr: QrVerification) -> Self {
Self::QrV1(qr)
}
}