From 82a99b5267dafe36a5cf113af535198ba2ce5cf8 Mon Sep 17 00:00:00 2001 From: Alexander Sieg Date: Fri, 10 Sep 2021 16:26:21 +0200 Subject: [PATCH] address code review issues --- matrix_sdk/README.md | 2 ++ matrix_sdk/src/identities/devices.rs | 3 ++- matrix_sdk/src/identities/users.rs | 3 ++- matrix_sdk_crypto/src/lib.rs | 2 ++ matrix_sdk_crypto/src/verification/cache.rs | 2 ++ matrix_sdk_crypto/src/verification/mod.rs | 4 ++++ matrix_sdk_crypto/src/verification/requests.rs | 10 ++++++++-- 7 files changed, 22 insertions(+), 4 deletions(-) diff --git a/matrix_sdk/README.md b/matrix_sdk/README.md index 6fa378ec..80898baf 100644 --- a/matrix_sdk/README.md +++ b/matrix_sdk/README.md @@ -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 diff --git a/matrix_sdk/src/identities/devices.rs b/matrix_sdk/src/identities/devices.rs index fb89ee56..1580d5e8 100644 --- a/matrix_sdk/src/identities/devices.rs +++ b/matrix_sdk/src/identities/devices.rs @@ -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 /// diff --git a/matrix_sdk/src/identities/users.rs b/matrix_sdk/src/identities/users.rs index 5cf55332..871eee73 100644 --- a/matrix_sdk/src/identities/users.rs +++ b/matrix_sdk/src/identities/users.rs @@ -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 /// diff --git a/matrix_sdk_crypto/src/lib.rs b/matrix_sdk_crypto/src/lib.rs index 26e58f51..cd283ee9 100644 --- a/matrix_sdk_crypto/src/lib.rs +++ b/matrix_sdk_crypto/src/lib.rs @@ -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}; diff --git a/matrix_sdk_crypto/src/verification/cache.rs b/matrix_sdk_crypto/src/verification/cache.rs index 596b55a5..ea9fb771 100644 --- a/matrix_sdk_crypto/src/verification/cache.rs +++ b/matrix_sdk_crypto/src/verification/cache.rs @@ -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 { self.get(sender, flow_id).and_then(|v| { if let Verification::QrV1(qr) = v { diff --git a/matrix_sdk_crypto/src/verification/mod.rs b/matrix_sdk_crypto/src/verification/mod.rs index d98c249c..1d0eb5ad 100644 --- a/matrix_sdk_crypto/src/verification/mod.rs +++ b/matrix_sdk_crypto/src/verification/mod.rs @@ -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 { if let Verification::QrV1(qr) = self { @@ -205,6 +208,7 @@ impl From for Verification { } #[cfg(feature = "qrcode")] +#[cfg_attr(feature = "docs", doc(cfg(qrcode)))] impl From for Verification { fn from(qr: QrVerification) -> Self { Self::QrV1(qr) diff --git a/matrix_sdk_crypto/src/verification/requests.rs b/matrix_sdk_crypto/src/verification/requests.rs index d9a59840..b300ea06 100644 --- a/matrix_sdk_crypto/src/verification/requests.rs +++ b/matrix_sdk_crypto/src/verification/requests.rs @@ -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, 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 {