address code review issues

master
Alexander Sieg 2021-09-10 16:26:21 +02:00
parent 349e3cae06
commit 82a99b5267
7 changed files with 22 additions and 4 deletions

View File

@ -45,6 +45,8 @@ More examples can be found in the [examples] directory.
The following crate feature flags are available:
* `encryption`: Enables end-to-end encryption support in the library.
* `qrcode`: Enables qrcode verification support in the library. This will also
enable `encryption`. Enabled by default.
* `sled_cryptostore`: Enables a Sled based store for the encryption keys. If
this is disabled and `encryption` support is enabled the keys will by
default be stored only in memory and thus lost after the client is

View File

@ -55,7 +55,8 @@ impl Device {
/// The default methods that are supported are `m.sas.v1` and
/// `m.qr_code.show.v1`, if this isn't desirable the
/// [`request_verification_with_methods()`] method can be used to override
/// this.
/// this. `m.qr_code.show.v1` is only avaliable if the `qrcode` feature is
/// enabled, which it is by default.
///
/// # Examples
///

View File

@ -82,7 +82,8 @@ impl UserIdentity {
/// The default methods that are supported are `m.sas.v1` and
/// `m.qr_code.show.v1`, if this isn't desirable the
/// [`request_verification_with_methods()`] method can be used to override
/// this.
/// this. `m.qr_code.show.v1` is only avaliable if the `qrcode` feature is
/// enabled, which it is by default.
///
/// # Examples
///

View File

@ -48,6 +48,7 @@ pub use identities::{
};
pub use machine::OlmMachine;
#[cfg(feature = "qrcode")]
#[cfg_attr(feature = "docs", doc(cfg(qrcode)))]
pub use matrix_qrcode;
pub(crate) use olm::ReadOnlyAccount;
pub use olm::{CrossSigningStatus, EncryptionSettings};
@ -57,5 +58,6 @@ pub use requests::{
};
pub use store::{CrossSigningKeyExport, CryptoStoreError, SecretImportError};
#[cfg(feature = "qrcode")]
#[cfg_attr(feature = "docs", doc(cfg(qrcode)))]
pub use verification::QrVerification;
pub use verification::{AcceptSettings, CancelInfo, Sas, Verification, VerificationRequest};

View File

@ -55,11 +55,13 @@ impl VerificationCache {
}
#[cfg(feature = "qrcode")]
#[cfg_attr(feature = "docs", doc(cfg(qrcode)))]
pub fn insert_qr(&self, qr: QrVerification) {
self.insert(qr)
}
#[cfg(feature = "qrcode")]
#[cfg_attr(feature = "docs", doc(cfg(qrcode)))]
pub fn get_qr(&self, sender: &UserId, flow_id: &str) -> Option<QrVerification> {
self.get(sender, flow_id).and_then(|v| {
if let Verification::QrV1(qr) = v {

View File

@ -29,6 +29,7 @@ use event_enums::OutgoingContent;
pub use machine::VerificationMachine;
use matrix_sdk_common::locks::Mutex;
#[cfg(feature = "qrcode")]
#[cfg_attr(feature = "docs", doc(cfg(qrcode)))]
pub use qrcode::QrVerification;
pub use requests::VerificationRequest;
use ruma::{
@ -118,6 +119,7 @@ pub enum Verification {
/// The `m.sas.v1` verification variant.
SasV1(Sas),
#[cfg(feature = "qrcode")]
#[cfg_attr(feature = "docs", doc(cfg(qrcode)))]
/// The `m.qr_code.*.v1` verification variant.
QrV1(QrVerification),
}
@ -134,6 +136,7 @@ impl Verification {
}
#[cfg(feature = "qrcode")]
#[cfg_attr(feature = "docs", doc(cfg(qrcode)))]
/// Try to deconstruct this verification enum into a QR code verification.
pub fn qr_v1(self) -> Option<QrVerification> {
if let Verification::QrV1(qr) = self {
@ -205,6 +208,7 @@ impl From<Sas> for Verification {
}
#[cfg(feature = "qrcode")]
#[cfg_attr(feature = "docs", doc(cfg(qrcode)))]
impl From<QrVerification> for Verification {
fn from(qr: QrVerification) -> Self {
Self::QrV1(qr)

View File

@ -59,6 +59,7 @@ use crate::{
const SUPPORTED_METHODS: &[VerificationMethod] = &[
VerificationMethod::SasV1,
#[cfg(feature = "qrcode")]
VerificationMethod::QrCodeShowV1,
VerificationMethod::ReciprocateV1,
];
@ -307,6 +308,7 @@ impl VerificationRequest {
}
#[cfg(feature = "qrcode")]
#[cfg_attr(feature = "docs", doc(cfg(qrcode)))]
/// Generate a QR code that can be used by another client to start a QR code
/// based verification.
pub async fn generate_qr_code(&self) -> Result<Option<QrVerification>, CryptoStoreError> {
@ -318,6 +320,7 @@ impl VerificationRequest {
}
///
#[cfg(feature = "qrcode")]
#[cfg_attr(feature = "docs", doc(cfg(qrcode)))]
/// Start a QR code verification by providing a scanned QR code for this
/// verification flow.
///
@ -408,8 +411,11 @@ impl VerificationRequest {
/// This method will accept the request and signal that it supports the
/// `m.sas.v1`, the `m.qr_code.show.v1`, and `m.reciprocate.v1` method.
///
/// If QR code scanning should be supported or QR code showing shouldn't be
/// supported the [`accept_with_methods()`] method should be used instead.
/// `m.qr_code.show.v1` will only be signaled if the `qrcode` feature is
/// enabled. This feature is disabled by default. If it's enabeled and QR
/// code scanning should be supported or QR code showing shouldn't be
/// supported the [`accept_with_methods()`] method should be used
/// instead.
///
/// [`accept_with_methods()`]: #method.accept_with_methods
pub fn accept(&self) -> Option<OutgoingVerificationRequest> {