From 7fda431d5fa98cd2c82343098b2d7800fcd4d5a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Mon, 15 Aug 2022 15:32:23 +0200 Subject: [PATCH] Remove the usage of the Ruma EventEncryptionAlgorithm --- bindings/matrix-sdk-crypto-js/src/encryption.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/bindings/matrix-sdk-crypto-js/src/encryption.rs b/bindings/matrix-sdk-crypto-js/src/encryption.rs index 27279de01..aa4d1c65a 100644 --- a/bindings/matrix-sdk-crypto-js/src/encryption.rs +++ b/bindings/matrix-sdk-crypto-js/src/encryption.rs @@ -41,7 +41,7 @@ impl Default for EncryptionSettings { let default = matrix_sdk_crypto::olm::EncryptionSettings::default(); Self { - algorithm: ruma::EventEncryptionAlgorithm::from(default.algorithm.as_str()).into(), + algorithm: default.algorithm.into(), rotation_period: default.rotation_period.as_micros().try_into().unwrap(), rotation_period_messages: default.rotation_period_msgs, history_visibility: default.history_visibility.into(), @@ -61,11 +61,10 @@ impl EncryptionSettings { impl From<&EncryptionSettings> for matrix_sdk_crypto::olm::EncryptionSettings { fn from(value: &EncryptionSettings) -> Self { - let algorithm: ruma::EventEncryptionAlgorithm = value.algorithm.clone().into(); + let algorithm = value.algorithm.clone().into(); Self { - algorithm: matrix_sdk_crypto::types::EventEncryptionAlgorithm::from(algorithm.as_str()) - .into(), + algorithm, rotation_period: Duration::from_micros(value.rotation_period), rotation_period_msgs: value.rotation_period_messages, history_visibility: value.history_visibility.clone().into(), @@ -86,7 +85,7 @@ pub enum EncryptionAlgorithm { MegolmV1AesSha2, } -impl From for ruma::EventEncryptionAlgorithm { +impl From for matrix_sdk_crypto::types::EventEncryptionAlgorithm { fn from(value: EncryptionAlgorithm) -> Self { use EncryptionAlgorithm::*; @@ -97,9 +96,9 @@ impl From for ruma::EventEncryptionAlgorithm { } } -impl From for EncryptionAlgorithm { - fn from(value: ruma::EventEncryptionAlgorithm) -> Self { - use ruma::EventEncryptionAlgorithm::*; +impl From for EncryptionAlgorithm { + fn from(value: matrix_sdk_crypto::types::EventEncryptionAlgorithm) -> Self { + use matrix_sdk_crypto::types::EventEncryptionAlgorithm::*; match value { OlmV1Curve25519AesSha2 => Self::OlmV1Curve25519AesSha2,