From 3414a59b913f8933fc50d6d8cd47013138711048 Mon Sep 17 00:00:00 2001 From: Johannes Becker Date: Fri, 16 Apr 2021 12:45:21 +0200 Subject: [PATCH] chore: bump ruma --- matrix_sdk/src/client.rs | 4 ++-- matrix_sdk/src/http_client.rs | 6 +++--- matrix_sdk_common/Cargo.toml | 2 +- matrix_sdk_common/src/lib.rs | 2 +- matrix_sdk_crypto/benches/crypto_bench.rs | 10 ++++++---- matrix_sdk_crypto/src/identities/manager.rs | 9 ++++++--- matrix_sdk_crypto/src/machine.rs | 8 +++++--- .../src/session_manager/group_sessions.rs | 9 +++++---- matrix_sdk_test/src/lib.rs | 7 ++++--- 9 files changed, 33 insertions(+), 24 deletions(-) diff --git a/matrix_sdk/src/client.rs b/matrix_sdk/src/client.rs index a6b6164b..e24ba4c6 100644 --- a/matrix_sdk/src/client.rs +++ b/matrix_sdk/src/client.rs @@ -2391,7 +2391,7 @@ mod test { .unwrap() .flows .iter() - .any(|flow| flow == &LoginType::Password); + .any(|flow| matches!(flow, LoginType::Password(_))); assert!(can_password); let _m_login = mock("POST", "/_matrix/client/r0/login") @@ -2465,7 +2465,7 @@ mod test { .unwrap() .flows .iter() - .any(|flow| flow == &LoginType::Sso); + .any(|flow| matches!(flow, LoginType::Sso(_))); assert!(can_sso); let sso_url = client.get_sso_login_url("http://127.0.0.1:3030"); diff --git a/matrix_sdk/src/http_client.rs b/matrix_sdk/src/http_client.rs index 1a34aae4..1eab2dd1 100644 --- a/matrix_sdk/src/http_client.rs +++ b/matrix_sdk/src/http_client.rs @@ -27,7 +27,7 @@ use url::Url; use matrix_sdk_common::{ api::r0::media::create_content, async_trait, locks::RwLock, AsyncTraitDeps, AuthScheme, - FromHttpResponseError, + FromHttpResponseError, IncomingResponse, }; use crate::{error::HttpError, ClientConfig, OutgoingRequest, RequestConfig, Session}; @@ -140,7 +140,7 @@ impl HttpClient { let response = self .send_request(request, self.session.clone(), config) .await?; - Ok(create_content::Response::try_from(response)?) + Ok(create_content::Response::try_from_http_response(response)?) } pub async fn send( @@ -158,7 +158,7 @@ impl HttpClient { trace!("Got response: {:?}", response); - let response = Request::IncomingResponse::try_from(response)?; + let response = Request::IncomingResponse::try_from_http_response(response)?; Ok(response) } diff --git a/matrix_sdk_common/Cargo.toml b/matrix_sdk_common/Cargo.toml index 5c89b13b..752fa730 100644 --- a/matrix_sdk_common/Cargo.toml +++ b/matrix_sdk_common/Cargo.toml @@ -22,7 +22,7 @@ async-trait = "0.1.42" [dependencies.ruma] version = "0.0.2" git = "https://github.com/ruma/ruma" -rev = "e2728a70812412aade9322f6ad832731978a4240" +rev = "47d6b458574247545f8836b9421800f0089f3008" features = ["client-api", "compat", "unstable-pre-spec"] [target.'cfg(not(target_arch = "wasm32"))'.dependencies] diff --git a/matrix_sdk_common/src/lib.rs b/matrix_sdk_common/src/lib.rs index dc4805f9..c2131e52 100644 --- a/matrix_sdk_common/src/lib.rs +++ b/matrix_sdk_common/src/lib.rs @@ -4,7 +4,7 @@ pub use ruma::{ api::{ client as api, error::{FromHttpRequestError, FromHttpResponseError, IntoHttpError, ServerError}, - AuthScheme, EndpointError, OutgoingRequest, + AuthScheme, EndpointError, IncomingResponse, OutgoingRequest, }, assign, directory, encryption, events, identifiers, int, presence, push, serde::{CanonicalJsonValue, Raw}, diff --git a/matrix_sdk_crypto/benches/crypto_bench.rs b/matrix_sdk_crypto/benches/crypto_bench.rs index 271be9b7..f2b23110 100644 --- a/matrix_sdk_crypto/benches/crypto_bench.rs +++ b/matrix_sdk_crypto/benches/crypto_bench.rs @@ -1,7 +1,7 @@ #[cfg(target_os = "linux")] mod perf; -use std::{convert::TryFrom, sync::Arc}; +use std::sync::Arc; use criterion::*; @@ -12,6 +12,7 @@ use matrix_sdk_common::{ }, identifiers::{room_id, user_id, DeviceIdBox, UserId}, uuid::Uuid, + IncomingResponse, }; use matrix_sdk_crypto::{EncryptionSettings, OlmMachine}; use matrix_sdk_test::response_from_file; @@ -30,21 +31,22 @@ fn keys_query_response() -> get_keys::Response { let data = include_bytes!("./keys_query.json"); let data: Value = serde_json::from_slice(data).unwrap(); let data = response_from_file(&data); - get_keys::Response::try_from(data).expect("Can't parse the keys upload response") + get_keys::Response::try_from_http_response(data).expect("Can't parse the keys upload response") } fn keys_claim_response() -> claim_keys::Response { let data = include_bytes!("./keys_claim.json"); let data: Value = serde_json::from_slice(data).unwrap(); let data = response_from_file(&data); - claim_keys::Response::try_from(data).expect("Can't parse the keys upload response") + claim_keys::Response::try_from_http_response(data) + .expect("Can't parse the keys upload response") } fn huge_keys_query_resopnse() -> get_keys::Response { let data = include_bytes!("./keys_query_2000_members.json"); let data: Value = serde_json::from_slice(data).unwrap(); let data = response_from_file(&data); - get_keys::Response::try_from(data).expect("Can't parse the keys query response") + get_keys::Response::try_from_http_response(data).expect("Can't parse the keys query response") } pub fn keys_query(c: &mut Criterion) { diff --git a/matrix_sdk_crypto/src/identities/manager.rs b/matrix_sdk_crypto/src/identities/manager.rs index 5a1a9b58..ed91272e 100644 --- a/matrix_sdk_crypto/src/identities/manager.rs +++ b/matrix_sdk_crypto/src/identities/manager.rs @@ -416,12 +416,13 @@ impl IdentityManager { #[cfg(test)] pub(crate) mod test { - use std::{convert::TryFrom, sync::Arc}; + use std::sync::Arc; use matrix_sdk_common::{ api::r0::keys::get_keys::Response as KeyQueryResponse, identifiers::{user_id, DeviceIdBox, UserId}, locks::Mutex, + IncomingResponse, }; use matrix_sdk_test::async_test; @@ -518,7 +519,8 @@ pub(crate) mod test { }, "user_signing_keys": {} })); - KeyQueryResponse::try_from(data).expect("Can't parse the keys upload response") + KeyQueryResponse::try_from_http_response(data) + .expect("Can't parse the keys upload response") } pub(crate) fn own_key_query() -> KeyQueryResponse { @@ -618,7 +620,8 @@ pub(crate) mod test { } } })); - KeyQueryResponse::try_from(data).expect("Can't parse the keys upload response") + KeyQueryResponse::try_from_http_response(data) + .expect("Can't parse the keys upload response") } #[async_test] diff --git a/matrix_sdk_crypto/src/machine.rs b/matrix_sdk_crypto/src/machine.rs index 415b80f7..b4d40f8d 100644 --- a/matrix_sdk_crypto/src/machine.rs +++ b/matrix_sdk_crypto/src/machine.rs @@ -1217,7 +1217,7 @@ pub(crate) mod test { identifiers::{ event_id, room_id, user_id, DeviceId, DeviceKeyAlgorithm, DeviceKeyId, UserId, }, - Raw, + IncomingResponse, Raw, }; use matrix_sdk_test::test_json; @@ -1247,12 +1247,14 @@ pub(crate) mod test { fn keys_upload_response() -> upload_keys::Response { let data = response_from_file(&test_json::KEYS_UPLOAD); - upload_keys::Response::try_from(data).expect("Can't parse the keys upload response") + upload_keys::Response::try_from_http_response(data) + .expect("Can't parse the keys upload response") } fn keys_query_response() -> get_keys::Response { let data = response_from_file(&test_json::KEYS_QUERY); - get_keys::Response::try_from(data).expect("Can't parse the keys upload response") + get_keys::Response::try_from_http_response(data) + .expect("Can't parse the keys upload response") } fn to_device_requests_to_content(requests: Vec>) -> EncryptedEventContent { diff --git a/matrix_sdk_crypto/src/session_manager/group_sessions.rs b/matrix_sdk_crypto/src/session_manager/group_sessions.rs index 649664a8..df73f84b 100644 --- a/matrix_sdk_crypto/src/session_manager/group_sessions.rs +++ b/matrix_sdk_crypto/src/session_manager/group_sessions.rs @@ -536,12 +536,11 @@ impl GroupSessionManager { #[cfg(test)] mod test { - use std::convert::TryFrom; - use matrix_sdk_common::{ api::r0::keys::{claim_keys, get_keys}, identifiers::{room_id, user_id, DeviceIdBox, UserId}, uuid::Uuid, + IncomingResponse, }; use matrix_sdk_test::response_from_file; use serde_json::Value; @@ -560,14 +559,16 @@ mod test { let data = include_bytes!("../../benches/keys_query.json"); let data: Value = serde_json::from_slice(data).unwrap(); let data = response_from_file(&data); - get_keys::Response::try_from(data).expect("Can't parse the keys upload response") + get_keys::Response::try_from_http_response(data) + .expect("Can't parse the keys upload response") } fn keys_claim_response() -> claim_keys::Response { let data = include_bytes!("../../benches/keys_claim.json"); let data: Value = serde_json::from_slice(data).unwrap(); let data = response_from_file(&data); - claim_keys::Response::try_from(data).expect("Can't parse the keys upload response") + claim_keys::Response::try_from_http_response(data) + .expect("Can't parse the keys upload response") } async fn machine() -> OlmMachine { diff --git a/matrix_sdk_test/src/lib.rs b/matrix_sdk_test/src/lib.rs index d1ed7e78..3ccf8f2b 100644 --- a/matrix_sdk_test/src/lib.rs +++ b/matrix_sdk_test/src/lib.rs @@ -1,4 +1,4 @@ -use std::{collections::HashMap, convert::TryFrom, panic}; +use std::{collections::HashMap, panic}; use http::Response; @@ -9,6 +9,7 @@ use matrix_sdk_common::{ AnySyncStateEvent, }, identifiers::{room_id, RoomId}, + IncomingResponse, }; use serde_json::Value as JsonValue; @@ -330,7 +331,7 @@ impl EventBuilder { // Clear state so that the next sync response will be empty if nothing was added. self.clear(); - SyncResponse::try_from(response).unwrap() + SyncResponse::try_from_http_response(response).unwrap() } fn generate_sync_token(&self) -> String { @@ -372,7 +373,7 @@ pub fn sync_response(kind: SyncResponseFile) -> SyncResponse { let response = Response::builder() .body(data.to_string().as_bytes().to_vec()) .unwrap(); - SyncResponse::try_from(response).unwrap() + SyncResponse::try_from_http_response(response).unwrap() } pub fn response_from_file(json: &serde_json::Value) -> Response> {