From 0c8e870bff6ec5163d907de8ca052c5c41af68f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Tue, 25 May 2021 21:33:38 +0200 Subject: [PATCH] crypto: Implement From for EncryptionInfo --- matrix_sdk_crypto/src/file_encryption/attachments.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/matrix_sdk_crypto/src/file_encryption/attachments.rs b/matrix_sdk_crypto/src/file_encryption/attachments.rs index 81c3cf23..70354f1f 100644 --- a/matrix_sdk_crypto/src/file_encryption/attachments.rs +++ b/matrix_sdk_crypto/src/file_encryption/attachments.rs @@ -23,7 +23,7 @@ use aes_ctr::{ }; use base64::DecodeError; use getrandom::getrandom; -use matrix_sdk_common::events::room::{JsonWebKey, JsonWebKeyInit}; +use matrix_sdk_common::events::room::{EncryptedFile, JsonWebKey, JsonWebKeyInit}; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; use thiserror::Error; @@ -252,6 +252,12 @@ pub struct EncryptionInfo { pub hashes: BTreeMap, } +impl From for EncryptionInfo { + fn from(file: EncryptedFile) -> Self { + Self { version: file.v, web_key: file.key, iv: file.iv, hashes: file.hashes } + } +} + #[cfg(test)] mod test { use std::io::{Cursor, Read};