crypto: Add a couple more getters for the SAS verification

master
Damir Jelić 2021-06-24 12:13:06 +02:00
parent c78406ceb9
commit 9a685d685c
2 changed files with 22 additions and 0 deletions

View File

@ -312,6 +312,18 @@ impl InnerSas {
matches!(self, InnerSas::Cancelled(_))
}
pub fn have_we_confirmed(&self) -> bool {
matches!(self, InnerSas::Confirmed(_) | InnerSas::WaitingForDone(_) | InnerSas::Done(_))
}
pub fn cancel_code(&self) -> Option<CancelCode> {
if let InnerSas::Cancelled(c) = self {
Some(c.state.cancel_code.clone())
} else {
None
}
}
pub fn timed_out(&self) -> bool {
match self {
InnerSas::Created(s) => s.timed_out(),

View File

@ -104,6 +104,16 @@ impl Sas {
self.identities_being_verified.is_self_verification()
}
/// Have we confirmed that the short auth string matches.
pub fn have_we_confirmed(&self) -> bool {
self.inner.lock().unwrap().have_we_confirmed()
}
/// Get the cancel code of this SAS verification if it has been cancelled
pub fn cancel_code(&self) -> Option<CancelCode> {
self.inner.lock().unwrap().cancel_code()
}
#[cfg(test)]
#[allow(dead_code)]
pub(crate) fn set_creation_time(&self, time: Instant) {