From c5241af6757f71351e23bc673be670ec8e3144a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Thu, 4 Mar 2021 17:46:18 +0100 Subject: [PATCH] crypto: Expose the crypto store error pulicly --- matrix_sdk_base/src/error.rs | 8 +++++++- matrix_sdk_crypto/src/lib.rs | 1 + matrix_sdk_crypto/src/machine.rs | 2 +- matrix_sdk_crypto/src/session_manager/sessions.rs | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/matrix_sdk_base/src/error.rs b/matrix_sdk_base/src/error.rs index 254f24be..ef28dad4 100644 --- a/matrix_sdk_base/src/error.rs +++ b/matrix_sdk_base/src/error.rs @@ -20,7 +20,7 @@ use std::io::Error as IoError; use thiserror::Error; #[cfg(feature = "encryption")] -use matrix_sdk_crypto::{MegolmError, OlmError}; +use matrix_sdk_crypto::{CryptoStoreError, MegolmError, OlmError}; /// Result type of the rust-sdk. pub type Result = std::result::Result; @@ -45,6 +45,12 @@ pub enum Error { #[error(transparent)] IoError(#[from] IoError), + /// An error occurred in the crypto store. + #[cfg(feature = "encryption")] + #[cfg_attr(feature = "docs", doc(cfg(encryption)))] + #[error(transparent)] + CryptoStore(#[from] CryptoStoreError), + /// An error occurred during a E2EE operation. #[cfg(feature = "encryption")] #[cfg_attr(feature = "docs", doc(cfg(encryption)))] diff --git a/matrix_sdk_crypto/src/lib.rs b/matrix_sdk_crypto/src/lib.rs index ce262a2c..e5fcfad3 100644 --- a/matrix_sdk_crypto/src/lib.rs +++ b/matrix_sdk_crypto/src/lib.rs @@ -54,4 +54,5 @@ pub use requests::{ IncomingResponse, KeysQueryRequest, OutgoingRequest, OutgoingRequests, OutgoingVerificationRequest, RoomMessageRequest, ToDeviceRequest, }; +pub use store::CryptoStoreError; pub use verification::{Sas, VerificationRequest}; diff --git a/matrix_sdk_crypto/src/machine.rs b/matrix_sdk_crypto/src/machine.rs index a85d20d9..71df69ec 100644 --- a/matrix_sdk_crypto/src/machine.rs +++ b/matrix_sdk_crypto/src/machine.rs @@ -504,7 +504,7 @@ impl OlmMachine { pub async fn get_missing_sessions( &self, users: impl Iterator, - ) -> OlmResult> { + ) -> StoreResult> { self.session_manager.get_missing_sessions(users).await } diff --git a/matrix_sdk_crypto/src/session_manager/sessions.rs b/matrix_sdk_crypto/src/session_manager/sessions.rs index 311cb572..8742fb10 100644 --- a/matrix_sdk_crypto/src/session_manager/sessions.rs +++ b/matrix_sdk_crypto/src/session_manager/sessions.rs @@ -189,7 +189,7 @@ impl SessionManager { pub async fn get_missing_sessions( &self, users: impl Iterator, - ) -> OlmResult> { + ) -> StoreResult> { let mut missing = BTreeMap::new(); // Add the list of devices that the user wishes to establish sessions