#[cfg(feature = "qrcode")]
mod qrcode;
mod requests;
mod sas;
use as_variant::as_variant;
pub use matrix_sdk_base::crypto::{
AcceptSettings, AcceptedProtocols, CancelInfo, Emoji, EmojiShortAuthString, SasState,
format_emojis,
};
#[cfg(feature = "qrcode")]
pub use matrix_sdk_base::crypto::{
QrVerificationState, ScanError,
matrix_sdk_qrcode::{DecodingError, EncodingError, QrVerificationData},
};
#[cfg(feature = "qrcode")]
pub use qrcode::QrVerification;
pub use requests::{VerificationRequest, VerificationRequestState};
use ruma::RoomId;
pub use sas::SasVerification;
#[derive(Debug, Clone)]
#[non_exhaustive]
pub enum Verification {
SasV1(SasVerification),
#[cfg(feature = "qrcode")]
QrV1(QrVerification),
}
impl Verification {
pub fn sas(self) -> Option<SasVerification> {
as_variant!(self, Verification::SasV1)
}
#[cfg(feature = "qrcode")]
pub fn qr(self) -> Option<QrVerification> {
as_variant!(self, Verification::QrV1)
}
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(),
}
}
pub fn room_id(&self) -> Option<&RoomId> {
match self {
Verification::SasV1(s) => s.room_id(),
#[cfg(feature = "qrcode")]
Verification::QrV1(q) => q.room_id(),
}
}
}
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)
}
}