From 30de5372eb305a87f2d65f7fb2ff61da43845e9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Sun, 5 Apr 2026 14:37:25 +0200 Subject: [PATCH] Upgrade Ruma after api::Error breaking change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kévin Commaille --- Cargo.lock | 20 ++++---- Cargo.toml | 2 +- bindings/matrix-sdk-ffi/src/client.rs | 16 ++++--- bindings/matrix-sdk-ffi/src/error.rs | 2 +- crates/matrix-sdk-ui/src/sync_service.rs | 3 +- .../tests/integration/timeline/queue.rs | 2 +- crates/matrix-sdk/src/account.rs | 16 +++---- .../src/authentication/matrix/mod.rs | 2 +- .../src/authentication/oauth/mod.rs | 4 +- .../src/authentication/oauth/qrcode/mod.rs | 2 +- .../qrcode/rendezvous_channel/msc_4108.rs | 2 +- crates/matrix-sdk/src/client/builder/mod.rs | 2 +- crates/matrix-sdk/src/client/futures.rs | 4 +- crates/matrix-sdk/src/client/mod.rs | 3 +- .../matrix-sdk/src/encryption/backups/mod.rs | 4 +- crates/matrix-sdk/src/encryption/mod.rs | 22 +++++---- crates/matrix-sdk/src/error.rs | 34 ++++--------- crates/matrix-sdk/src/media.rs | 3 +- crates/matrix-sdk/src/room/mod.rs | 48 ++++++++++--------- .../src/room/shared_room_history.rs | 2 +- crates/matrix-sdk/src/sliding_sync/mod.rs | 2 +- .../src/widget/machine/from_widget.rs | 6 ++- .../tests/integration/matrix_auth.rs | 21 ++++---- .../tests/integration/refresh_token.rs | 6 +-- 24 files changed, 108 insertions(+), 120 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6198081c0..0786d67d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4917,7 +4917,7 @@ dependencies = [ [[package]] name = "ruma" version = "0.14.1" -source = "git+https://github.com/ruma/ruma?rev=390d07ba915003fb8c5c625cf461d4c43370fa6a#390d07ba915003fb8c5c625cf461d4c43370fa6a" +source = "git+https://github.com/ruma/ruma?rev=7680eebd9586669e1a4e5b1fd1c2c691221369d4#7680eebd9586669e1a4e5b1fd1c2c691221369d4" dependencies = [ "assign", "js_int", @@ -4935,12 +4935,11 @@ dependencies = [ [[package]] name = "ruma-client-api" version = "0.22.1" -source = "git+https://github.com/ruma/ruma?rev=390d07ba915003fb8c5c625cf461d4c43370fa6a#390d07ba915003fb8c5c625cf461d4c43370fa6a" +source = "git+https://github.com/ruma/ruma?rev=7680eebd9586669e1a4e5b1fd1c2c691221369d4#7680eebd9586669e1a4e5b1fd1c2c691221369d4" dependencies = [ "as_variant", "assign", "bytes", - "date_header", "http", "js_int", "js_option", @@ -4958,11 +4957,12 @@ dependencies = [ [[package]] name = "ruma-common" version = "0.17.1" -source = "git+https://github.com/ruma/ruma?rev=390d07ba915003fb8c5c625cf461d4c43370fa6a#390d07ba915003fb8c5c625cf461d4c43370fa6a" +source = "git+https://github.com/ruma/ruma?rev=7680eebd9586669e1a4e5b1fd1c2c691221369d4#7680eebd9586669e1a4e5b1fd1c2c691221369d4" dependencies = [ "as_variant", "base64", "bytes", + "date_header", "form_urlencoded", "getrandom 0.2.15", "http", @@ -4990,7 +4990,7 @@ dependencies = [ [[package]] name = "ruma-events" version = "0.32.1" -source = "git+https://github.com/ruma/ruma?rev=390d07ba915003fb8c5c625cf461d4c43370fa6a#390d07ba915003fb8c5c625cf461d4c43370fa6a" +source = "git+https://github.com/ruma/ruma?rev=7680eebd9586669e1a4e5b1fd1c2c691221369d4#7680eebd9586669e1a4e5b1fd1c2c691221369d4" dependencies = [ "as_variant", "indexmap", @@ -5013,7 +5013,7 @@ dependencies = [ [[package]] name = "ruma-federation-api" version = "0.13.1" -source = "git+https://github.com/ruma/ruma?rev=390d07ba915003fb8c5c625cf461d4c43370fa6a#390d07ba915003fb8c5c625cf461d4c43370fa6a" +source = "git+https://github.com/ruma/ruma?rev=7680eebd9586669e1a4e5b1fd1c2c691221369d4#7680eebd9586669e1a4e5b1fd1c2c691221369d4" dependencies = [ "headers", "http", @@ -5034,7 +5034,7 @@ dependencies = [ [[package]] name = "ruma-html" version = "0.6.0" -source = "git+https://github.com/ruma/ruma?rev=390d07ba915003fb8c5c625cf461d4c43370fa6a#390d07ba915003fb8c5c625cf461d4c43370fa6a" +source = "git+https://github.com/ruma/ruma?rev=7680eebd9586669e1a4e5b1fd1c2c691221369d4#7680eebd9586669e1a4e5b1fd1c2c691221369d4" dependencies = [ "as_variant", "html5ever", @@ -5045,7 +5045,7 @@ dependencies = [ [[package]] name = "ruma-identifiers-validation" version = "0.12.0" -source = "git+https://github.com/ruma/ruma?rev=390d07ba915003fb8c5c625cf461d4c43370fa6a#390d07ba915003fb8c5c625cf461d4c43370fa6a" +source = "git+https://github.com/ruma/ruma?rev=7680eebd9586669e1a4e5b1fd1c2c691221369d4#7680eebd9586669e1a4e5b1fd1c2c691221369d4" dependencies = [ "js_int", "thiserror 2.0.17", @@ -5054,7 +5054,7 @@ dependencies = [ [[package]] name = "ruma-macros" version = "0.17.1" -source = "git+https://github.com/ruma/ruma?rev=390d07ba915003fb8c5c625cf461d4c43370fa6a#390d07ba915003fb8c5c625cf461d4c43370fa6a" +source = "git+https://github.com/ruma/ruma?rev=7680eebd9586669e1a4e5b1fd1c2c691221369d4#7680eebd9586669e1a4e5b1fd1c2c691221369d4" dependencies = [ "as_variant", "cfg-if", @@ -5070,7 +5070,7 @@ dependencies = [ [[package]] name = "ruma-signatures" version = "0.19.0" -source = "git+https://github.com/ruma/ruma?rev=390d07ba915003fb8c5c625cf461d4c43370fa6a#390d07ba915003fb8c5c625cf461d4c43370fa6a" +source = "git+https://github.com/ruma/ruma?rev=7680eebd9586669e1a4e5b1fd1c2c691221369d4#7680eebd9586669e1a4e5b1fd1c2c691221369d4" dependencies = [ "base64", "ed25519-dalek", diff --git a/Cargo.toml b/Cargo.toml index c4b6bcc81..a45a21a40 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -71,7 +71,7 @@ rand = { version = "0.10.0", default-features = false, features = ["std", "std_r regex = { version = "1.12.2", default-features = false } reqwest = { version = "0.13.1", default-features = false } rmp-serde = { version = "1.3.0", default-features = false } -ruma = { git = "https://github.com/ruma/ruma", rev = "390d07ba915003fb8c5c625cf461d4c43370fa6a", features = [ +ruma = { git = "https://github.com/ruma/ruma", rev = "7680eebd9586669e1a4e5b1fd1c2c691221369d4", features = [ "client-api-c", "compat-unset-avatar", "compat-upload-signatures", diff --git a/bindings/matrix-sdk-ffi/src/client.rs b/bindings/matrix-sdk-ffi/src/client.rs index 03a830657..7ee38256a 100644 --- a/bindings/matrix-sdk-ffi/src/client.rs +++ b/bindings/matrix-sdk-ffi/src/client.rs @@ -71,15 +71,17 @@ use matrix_sdk_ui::{ use mime::Mime; use oauth2::Scope; use ruma::{ - api::client::{ - alias::get_alias, - discovery::get_authorization_server_metadata::v1::{ - AccountManagementActionData, DeviceDeleteData, DeviceViewData, + api::{ + client::{ + alias::get_alias, + discovery::get_authorization_server_metadata::v1::{ + AccountManagementActionData, DeviceDeleteData, DeviceViewData, + }, + profile::{AvatarUrl, DisplayName}, + room::create_room::{v3::CreationContent, RoomPowerLevelsContentOverride}, + uiaa::{EmailUserIdentifier, UserIdentifier}, }, error::ErrorKind, - profile::{AvatarUrl, DisplayName}, - room::create_room::{v3::CreationContent, RoomPowerLevelsContentOverride}, - uiaa::{EmailUserIdentifier, UserIdentifier}, }, events::{ direct::DirectEventContent, diff --git a/bindings/matrix-sdk-ffi/src/error.rs b/bindings/matrix-sdk-ffi/src/error.rs index 361b2ff72..97ff63b48 100644 --- a/bindings/matrix-sdk-ffi/src/error.rs +++ b/bindings/matrix-sdk-ffi/src/error.rs @@ -26,7 +26,7 @@ use matrix_sdk::{ }; use matrix_sdk_ui::{encryption_sync_service, notification_client, spaces, sync_service, timeline}; use ruma::{ - api::client::error::{ErrorBody, ErrorKind as RumaApiErrorKind, RetryAfter, StandardErrorBody}, + api::error::{ErrorBody, ErrorKind as RumaApiErrorKind, RetryAfter, StandardErrorBody}, MilliSecondsSinceUnixEpoch, }; use tracing::warn; diff --git a/crates/matrix-sdk-ui/src/sync_service.rs b/crates/matrix-sdk-ui/src/sync_service.rs index 1ea803f18..4c64ed355 100644 --- a/crates/matrix-sdk-ui/src/sync_service.rs +++ b/crates/matrix-sdk-ui/src/sync_service.rs @@ -742,8 +742,7 @@ impl TerminationReport { match &self.error { Some(Error::RoomList(room_list_service::Error::SlidingSync(error))) | Some(Error::EncryptionSync(encryption_sync_service::Error::SlidingSync(error))) => { - error.client_api_error_kind() - == Some(&ruma::api::client::error::ErrorKind::UnknownPos) + error.client_api_error_kind() == Some(&ruma::api::error::ErrorKind::UnknownPos) } _ => false, } diff --git a/crates/matrix-sdk-ui/tests/integration/timeline/queue.rs b/crates/matrix-sdk-ui/tests/integration/timeline/queue.rs index ba22c72db..10133ee06 100644 --- a/crates/matrix-sdk-ui/tests/integration/timeline/queue.rs +++ b/crates/matrix-sdk-ui/tests/integration/timeline/queue.rs @@ -315,7 +315,7 @@ async fn test_reloaded_failed_local_echoes_are_marked_as_failed() { // And it's properly pattern-matched as an HTTP error. assert_matches!( error.as_client_api_error().unwrap().error_kind(), - Some(ruma::api::client::error::ErrorKind::TooLarge) + Some(ruma::api::error::ErrorKind::TooLarge) ); assert_pending!(timeline_stream); diff --git a/crates/matrix-sdk/src/account.rs b/crates/matrix-sdk/src/account.rs index a3c56dd2f..7a28b937b 100644 --- a/crates/matrix-sdk/src/account.rs +++ b/crates/matrix-sdk/src/account.rs @@ -40,13 +40,13 @@ use ruma::{ request_3pid_management_token_via_email, request_3pid_management_token_via_msisdn, }, config::{get_global_account_data, set_global_account_data}, - error::ErrorKind, profile::{ DisplayName, StaticProfileField, delete_profile_field, get_avatar_url, get_profile, get_profile_field, set_avatar_url, set_display_name, set_profile_field, }, uiaa::AuthData, }, + error::ErrorKind, }, assign, events::{ @@ -379,7 +379,7 @@ impl Account { /// response, which would result in `Ok(None)`. Note that this error code /// might also mean that the given user ID doesn't exist. /// - /// [`ErrorCode::NotFound`]: ruma::api::client::error::ErrorCode::NotFound + /// [`ErrorCode::NotFound`]: ruma::api::error::ErrorCode::NotFound pub async fn fetch_profile_field_of( &self, user_id: OwnedUserId, @@ -411,7 +411,7 @@ impl Account { /// response, which would result in `Ok(None)`. Note that this error code /// might also mean that the given user ID doesn't exist. /// - /// [`ErrorCode::NotFound`]: ruma::api::client::error::ErrorCode::NotFound + /// [`ErrorCode::NotFound`]: ruma::api::error::ErrorCode::NotFound pub async fn fetch_profile_field_of_static( &self, user_id: OwnedUserId, @@ -517,7 +517,7 @@ impl Account { /// ``` /// [uiaa]: https://spec.matrix.org/v1.2/client-server-api/#user-interactive-authentication-api /// [`UiaaResponse`]: ruma::api::client::uiaa::UiaaResponse - /// [`ErrorKind::WeakPassword`]: ruma::api::client::error::ErrorKind::WeakPassword + /// [`ErrorKind::WeakPassword`]: ruma::api::error::ErrorKind::WeakPassword pub async fn change_password( &self, new_password: &str, @@ -668,8 +668,8 @@ impl Account { /// # anyhow::Ok(()) }; /// ``` /// [3pid]: https://spec.matrix.org/v1.2/appendices/#3pid-types - /// [`ErrorKind::ThreepidInUse`]: ruma::api::client::error::ErrorKind::ThreepidInUse - /// [`ErrorKind::ThreepidDenied`]: ruma::api::client::error::ErrorKind::ThreepidDenied + /// [`ErrorKind::ThreepidInUse`]: ruma::api::error::ErrorKind::ThreepidInUse + /// [`ErrorKind::ThreepidDenied`]: ruma::api::error::ErrorKind::ThreepidDenied pub async fn request_3pid_email_token( &self, client_secret: &ClientSecret, @@ -743,8 +743,8 @@ impl Account { /// # anyhow::Ok(()) }; /// ``` /// [3pid]: https://spec.matrix.org/v1.2/appendices/#3pid-types - /// [`ErrorKind::ThreepidInUse`]: ruma::api::client::error::ErrorKind::ThreepidInUse - /// [`ErrorKind::ThreepidDenied`]: ruma::api::client::error::ErrorKind::ThreepidDenied + /// [`ErrorKind::ThreepidInUse`]: ruma::api::error::ErrorKind::ThreepidInUse + /// [`ErrorKind::ThreepidDenied`]: ruma::api::error::ErrorKind::ThreepidDenied pub async fn request_3pid_msisdn_token( &self, client_secret: &ClientSecret, diff --git a/crates/matrix-sdk/src/authentication/matrix/mod.rs b/crates/matrix-sdk/src/authentication/matrix/mod.rs index 8aa684ea4..686fd748f 100644 --- a/crates/matrix-sdk/src/authentication/matrix/mod.rs +++ b/crates/matrix-sdk/src/authentication/matrix/mod.rs @@ -504,7 +504,7 @@ impl MatrixAuth { /// ``` /// /// [refreshing access tokens]: https://spec.matrix.org/v1.3/client-server-api/#refreshing-access-tokens - /// [`UnknownToken`]: ruma::api::client::error::ErrorKind::UnknownToken + /// [`UnknownToken`]: ruma::api::error::ErrorKind::UnknownToken /// [restore the session]: Client::restore_session /// [`ClientBuilder::handle_refresh_tokens()`]: crate::ClientBuilder::handle_refresh_tokens pub async fn refresh_access_token(&self) -> Result<(), RefreshTokenError> { diff --git a/crates/matrix-sdk/src/authentication/oauth/mod.rs b/crates/matrix-sdk/src/authentication/oauth/mod.rs index cecac8914..0bfe8d007 100644 --- a/crates/matrix-sdk/src/authentication/oauth/mod.rs +++ b/crates/matrix-sdk/src/authentication/oauth/mod.rs @@ -155,8 +155,8 @@ //! [MSC4108]: https://github.com/matrix-org/matrix-spec-proposals/pull/4108 //! [RFC 8628]: https://datatracker.ietf.org/doc/html/rfc8628 //! [`ClientBuilder::handle_refresh_tokens()`]: crate::ClientBuilder::handle_refresh_tokens() -//! [`Error`]: ruma::api::client::error::Error -//! [`ErrorKind::UnknownToken`]: ruma::api::client::error::ErrorKind::UnknownToken +//! [`Error`]: ruma::api::error::Error +//! [`ErrorKind::UnknownToken`]: ruma::api::error::ErrorKind::UnknownToken //! [`examples/oauth_cli`]: https://github.com/matrix-org/matrix-rust-sdk/tree/main/examples/oauth_cli #[cfg(feature = "e2e-encryption")] diff --git a/crates/matrix-sdk/src/authentication/oauth/qrcode/mod.rs b/crates/matrix-sdk/src/authentication/oauth/qrcode/mod.rs index 8dff86db0..7857eb22c 100644 --- a/crates/matrix-sdk/src/authentication/oauth/qrcode/mod.rs +++ b/crates/matrix-sdk/src/authentication/oauth/qrcode/mod.rs @@ -33,7 +33,7 @@ pub use oauth2::{ RequestTokenError, StandardErrorResponse, basic::{BasicErrorResponse, BasicRequestTokenError}, }; -use ruma::api::{client::error::ErrorKind, error::FromHttpResponseError}; +use ruma::api::error::{ErrorKind, FromHttpResponseError}; use thiserror::Error; use tokio::sync::Mutex; use url::Url; diff --git a/crates/matrix-sdk/src/authentication/oauth/qrcode/rendezvous_channel/msc_4108.rs b/crates/matrix-sdk/src/authentication/oauth/qrcode/rendezvous_channel/msc_4108.rs index a566c7eb5..192b03262 100644 --- a/crates/matrix-sdk/src/authentication/oauth/qrcode/rendezvous_channel/msc_4108.rs +++ b/crates/matrix-sdk/src/authentication/oauth/qrcode/rendezvous_channel/msc_4108.rs @@ -56,7 +56,7 @@ fn response_to_error(status: StatusCode, body: Vec) -> HttpError { match http::Response::builder().status(status).body(body).map_err(IntoHttpError::from) { Ok(response) => { let error = FromHttpResponseError::::Server(RumaApiError::ClientApi( - ruma::api::client::Error::from_http_response(response), + ruma::api::error::Error::from_http_response(response), )); error.into() diff --git a/crates/matrix-sdk/src/client/builder/mod.rs b/crates/matrix-sdk/src/client/builder/mod.rs index da8529ef1..2c51ffe0e 100644 --- a/crates/matrix-sdk/src/client/builder/mod.rs +++ b/crates/matrix-sdk/src/client/builder/mod.rs @@ -446,7 +446,7 @@ impl ClientBuilder { /// to be able to [restore the session] later. /// /// [refreshing access tokens]: https://spec.matrix.org/v1.3/client-server-api/#refreshing-access-tokens - /// [`UnknownToken`]: ruma::api::client::error::ErrorKind::UnknownToken + /// [`UnknownToken`]: ruma::api::error::ErrorKind::UnknownToken /// [restore the session]: Client::restore_session pub fn handle_refresh_tokens(mut self) -> Self { self.handle_refresh_tokens = true; diff --git a/crates/matrix-sdk/src/client/futures.rs b/crates/matrix-sdk/src/client/futures.rs index 33db6f9d3..1896e5925 100644 --- a/crates/matrix-sdk/src/client/futures.rs +++ b/crates/matrix-sdk/src/client/futures.rs @@ -22,8 +22,8 @@ use matrix_sdk_common::{SendOutsideWasm, SyncOutsideWasm, boxed_into_future}; use oauth2::{RequestTokenError, basic::BasicErrorResponseType}; use ruma::api::{ OutgoingRequest, - client::{error::ErrorKind, media}, - error::FromHttpResponseError, + client::media, + error::{ErrorKind, FromHttpResponseError}, path_builder::PathBuilder, }; use tracing::{error, trace}; diff --git a/crates/matrix-sdk/src/client/mod.rs b/crates/matrix-sdk/src/client/mod.rs index f361caeba..e96107277 100644 --- a/crates/matrix-sdk/src/client/mod.rs +++ b/crates/matrix-sdk/src/client/mod.rs @@ -61,7 +61,6 @@ use ruma::{ discover_homeserver::{self, RtcFocusInfo}, get_supported_versions, }, - error::{ErrorKind, UnknownTokenErrorData}, filter::{FilterDefinition, create_filter::v3::Request as FilterUploadRequest}, knock::knock_room, media, @@ -73,7 +72,7 @@ use ruma::{ uiaa, user_directory::search_users, }, - error::FromHttpResponseError, + error::{ErrorKind, FromHttpResponseError, UnknownTokenErrorData}, path_builder::PathBuilder, }, assign, diff --git a/crates/matrix-sdk/src/encryption/backups/mod.rs b/crates/matrix-sdk/src/encryption/backups/mod.rs index 97a6c103c..2a0b9716b 100644 --- a/crates/matrix-sdk/src/encryption/backups/mod.rs +++ b/crates/matrix-sdk/src/encryption/backups/mod.rs @@ -36,8 +36,8 @@ use matrix_sdk_base::crypto::{ use ruma::serde::JsonCastable; use ruma::{ OwnedRoomId, RoomId, TransactionId, - api::client::{ - backup::{ + api::{ + client::backup::{ RoomKeyBackup, add_backup_keys, create_backup_version, get_backup_keys, get_backup_keys_for_room, get_backup_keys_for_session, get_latest_backup_info, }, diff --git a/crates/matrix-sdk/src/encryption/mod.rs b/crates/matrix-sdk/src/encryption/mod.rs index 754f92c68..6a6fef97c 100644 --- a/crates/matrix-sdk/src/encryption/mod.rs +++ b/crates/matrix-sdk/src/encryption/mod.rs @@ -59,17 +59,19 @@ use matrix_sdk_base::{ use matrix_sdk_common::{executor::spawn, locks::Mutex as StdMutex}; use ruma::{ DeviceId, MilliSecondsSinceUnixEpoch, OwnedDeviceId, OwnedUserId, TransactionId, UserId, - api::client::{ + api::{ + client::{ + keys::{ + get_keys, upload_keys, upload_signatures::v3::Request as UploadSignaturesRequest, + upload_signing_keys::v3::Request as UploadSigningKeysRequest, + }, + message::send_message_event, + to_device::send_event_to_device::v3::{ + Request as RumaToDeviceRequest, Response as ToDeviceResponse, + }, + uiaa::{AuthData, AuthType, OAuthParams, UiaaInfo}, + }, error::{ErrorBody, StandardErrorBody}, - keys::{ - get_keys, upload_keys, upload_signatures::v3::Request as UploadSignaturesRequest, - upload_signing_keys::v3::Request as UploadSigningKeysRequest, - }, - message::send_message_event, - to_device::send_event_to_device::v3::{ - Request as RumaToDeviceRequest, Response as ToDeviceResponse, - }, - uiaa::{AuthData, AuthType, OAuthParams, UiaaInfo}, }, assign, events::room::{ diff --git a/crates/matrix-sdk/src/error.rs b/crates/matrix-sdk/src/error.rs index dd66161fa..8991149f0 100644 --- a/crates/matrix-sdk/src/error.rs +++ b/crates/matrix-sdk/src/error.rs @@ -33,11 +33,8 @@ use reqwest::Error as ReqwestError; use ruma::{ IdParseError, api::{ - client::{ - error::{ErrorKind, RetryAfter}, - uiaa::{UiaaInfo, UiaaResponse}, - }, - error::{FromHttpResponseError, IntoHttpError}, + client::uiaa::{UiaaInfo, UiaaResponse}, + error::{ErrorKind, FromHttpResponseError, IntoHttpError, RetryAfter}, }, events::{room::power_levels::PowerLevelsError, tag::InvalidUserTagName}, push::{InsertPushRuleError, RemovePushRuleError}, @@ -66,7 +63,7 @@ pub type HttpResult = std::result::Result; pub enum RumaApiError { /// A client API response error. #[error(transparent)] - ClientApi(ruma::api::client::Error), + ClientApi(ruma::api::error::Error), /// A user-interactive authentication API error. /// @@ -76,17 +73,13 @@ pub enum RumaApiError { /// authenticate the user. #[error("User-Interactive Authentication required.")] Uiaa(UiaaInfo), - - /// Another API response error. - #[error(transparent)] - Other(ruma::api::error::MatrixError), } impl RumaApiError { /// If `self` is `ClientApi(e)`, returns `Some(e)`. /// /// Otherwise, returns `None`. - pub fn as_client_api_error(&self) -> Option<&ruma::api::client::Error> { + pub fn as_client_api_error(&self) -> Option<&ruma::api::error::Error> { as_variant!(self, Self::ClientApi) } } @@ -137,7 +130,7 @@ impl HttpError { /// Shorthand for /// .[as_ruma_api_error](Self::as_ruma_api_error)().[and_then](Option::and_then)([RumaApiError::as_client_api_error]). - pub fn as_client_api_error(&self) -> Option<&ruma::api::client::Error> { + pub fn as_client_api_error(&self) -> Option<&ruma::api::error::Error> { self.as_ruma_api_error().and_then(RumaApiError::as_client_api_error) } } @@ -147,7 +140,7 @@ impl HttpError { /// If `self` is a server error in the `errcode` + `error` format expected /// for client-API endpoints, returns the error kind (`errcode`). pub fn client_api_error_kind(&self) -> Option<&ErrorKind> { - self.as_client_api_error().and_then(ruma::api::client::Error::error_kind) + self.as_client_api_error().and_then(ruma::api::error::Error::error_kind) } /// Try to destructure the error into an universal interactive auth info. @@ -224,7 +217,6 @@ impl RetryKind { Some(ErrorKind::Unrecognized) => RetryKind::Permanent, _ => RetryKind::from_status_code(client_error.status_code), }, - RumaApiError::Other(e) => RetryKind::from_status_code(e.status_code), RumaApiError::Uiaa(_) => RetryKind::Permanent, } } @@ -437,14 +429,14 @@ impl Error { /// Shorthand for /// .[as_ruma_api_error](Self::as_ruma_api_error)().[and_then](Option::and_then)([RumaApiError::as_client_api_error]). - pub fn as_client_api_error(&self) -> Option<&ruma::api::client::Error> { + pub fn as_client_api_error(&self) -> Option<&ruma::api::error::Error> { self.as_ruma_api_error().and_then(RumaApiError::as_client_api_error) } /// If `self` is a server error in the `errcode` + `error` format expected /// for client-API endpoints, returns the error kind (`errcode`). pub fn client_api_error_kind(&self) -> Option<&ErrorKind> { - self.as_client_api_error().and_then(ruma::api::client::Error::error_kind) + self.as_client_api_error().and_then(ruma::api::error::Error::error_kind) } /// Try to destructure the error into an universal interactive auth info. @@ -579,8 +571,8 @@ pub enum RoomKeyImportError { Export(#[from] KeyExportError), } -impl From> for HttpError { - fn from(err: FromHttpResponseError) -> Self { +impl From> for HttpError { + fn from(err: FromHttpResponseError) -> Self { Self::Api(Box::new(err.map(RumaApiError::ClientApi))) } } @@ -594,12 +586,6 @@ impl From> for HttpError { } } -impl From> for HttpError { - fn from(err: FromHttpResponseError) -> Self { - Self::Api(Box::new(err.map(RumaApiError::Other))) - } -} - impl From for Error { fn from(e: SdkBaseError) -> Self { match e { diff --git a/crates/matrix-sdk/src/media.rs b/crates/matrix-sdk/src/media.rs index 156284233..be821736d 100644 --- a/crates/matrix-sdk/src/media.rs +++ b/crates/matrix-sdk/src/media.rs @@ -30,7 +30,8 @@ use ruma::{ MilliSecondsSinceUnixEpoch, MxcUri, OwnedMxcUri, TransactionId, UInt, api::{ Metadata, - client::{authenticated_media, error::ErrorKind, media}, + client::{authenticated_media, media}, + error::ErrorKind, }, assign, events::room::{MediaSource, ThumbnailInfo}, diff --git a/crates/matrix-sdk/src/room/mod.rs b/crates/matrix-sdk/src/room/mod.rs index b26df2db3..7cbb617cc 100644 --- a/crates/matrix-sdk/src/room/mod.rs +++ b/crates/matrix-sdk/src/room/mod.rs @@ -78,31 +78,33 @@ use ruma::events::{ use ruma::{ EventId, Int, MatrixToUri, MatrixUri, MxcUri, OwnedEventId, OwnedRoomId, OwnedServerName, OwnedTransactionId, OwnedUserId, RoomId, TransactionId, UInt, UserId, - api::client::{ - config::{set_global_account_data, set_room_account_data}, - context, - error::ErrorKind, - filter::LazyLoadOptions, - membership::{ - Invite3pid, ban_user, forget_room, get_member_events, - invite_user::{ - self, - v3::{InvitationRecipient, InviteUserId}, + api::{ + client::{ + config::{set_global_account_data, set_room_account_data}, + context, + filter::LazyLoadOptions, + membership::{ + Invite3pid, ban_user, forget_room, get_member_events, + invite_user::{ + self, + v3::{InvitationRecipient, InviteUserId}, + }, + kick_user, leave_room, unban_user, + }, + message::send_message_event, + read_marker::set_read_marker, + receipt::create_receipt, + redact::redact_event, + room::{get_room_event, report_content, report_room}, + state::{get_state_event_for_key, send_state_event}, + tag::{create_tag, delete_tag}, + threads::{get_thread_subscription, subscribe_thread, unsubscribe_thread}, + typing::create_typing_event::{ + self, + v3::{Typing, TypingInfo}, }, - kick_user, leave_room, unban_user, - }, - message::send_message_event, - read_marker::set_read_marker, - receipt::create_receipt, - redact::redact_event, - room::{get_room_event, report_content, report_room}, - state::{get_state_event_for_key, send_state_event}, - tag::{create_tag, delete_tag}, - threads::{get_thread_subscription, subscribe_thread, unsubscribe_thread}, - typing::create_typing_event::{ - self, - v3::{Typing, TypingInfo}, }, + error::ErrorKind, }, assign, events::{ diff --git a/crates/matrix-sdk/src/room/shared_room_history.rs b/crates/matrix-sdk/src/room/shared_room_history.rs index a50071a86..81b012fc8 100644 --- a/crates/matrix-sdk/src/room/shared_room_history.rs +++ b/crates/matrix-sdk/src/room/shared_room_history.rs @@ -24,7 +24,7 @@ use matrix_sdk_base::{ }; use ruma::{ OwnedUserId, UserId, - api::client::error::ErrorKind, + api::error::ErrorKind, events::room::{MediaSource, history_visibility::HistoryVisibility}, }; use tracing::{debug, info, instrument, warn}; diff --git a/crates/matrix-sdk/src/sliding_sync/mod.rs b/crates/matrix-sdk/src/sliding_sync/mod.rs index b0b9e9a7f..5468bbded 100644 --- a/crates/matrix-sdk/src/sliding_sync/mod.rs +++ b/crates/matrix-sdk/src/sliding_sync/mod.rs @@ -38,7 +38,7 @@ use matrix_sdk_common::executor::JoinHandleExt as _; use matrix_sdk_common::{executor::spawn, timer}; use ruma::{ OwnedRoomId, RoomId, - api::client::{error::ErrorKind, sync::sync_events::v5 as http}, + api::{client::sync::sync_events::v5 as http, error::ErrorKind}, assign, }; use tokio::{ diff --git a/crates/matrix-sdk/src/widget/machine/from_widget.rs b/crates/matrix-sdk/src/widget/machine/from_widget.rs index f07f0cdfa..b87e8c1a0 100644 --- a/crates/matrix-sdk/src/widget/machine/from_widget.rs +++ b/crates/matrix-sdk/src/widget/machine/from_widget.rs @@ -17,8 +17,10 @@ use std::collections::BTreeMap; use as_variant::as_variant; use ruma::{ OwnedEventId, OwnedRoomId, - api::client::{ - delayed_events::{delayed_message_event, delayed_state_event, update_delayed_event}, + api::{ + client::delayed_events::{ + delayed_message_event, delayed_state_event, update_delayed_event, + }, error::{ErrorBody, StandardErrorBody}, }, events::AnyTimelineEvent, diff --git a/crates/matrix-sdk/tests/integration/matrix_auth.rs b/crates/matrix-sdk/tests/integration/matrix_auth.rs index 2ec511502..0c1205c84 100644 --- a/crates/matrix-sdk/tests/integration/matrix_auth.rs +++ b/crates/matrix-sdk/tests/integration/matrix_auth.rs @@ -12,15 +12,14 @@ use matrix_sdk_test::{async_test, test_json}; use ruma::{ OwnedUserId, api::{ - MatrixVersion, + self, MatrixVersion, client::{ - self as client_api, account::register::{RegistrationKind, v3::Request as RegistrationRequest}, - error::StandardErrorBody, keys::upload_signatures::v3::SignedKeys, session::get_login_types::v3::LoginType, uiaa::{self, AuthData, MatrixUserIdentifier, UserIdentifier}, }, + error::StandardErrorBody, }, assign, encryption::CrossSigningKey, @@ -128,7 +127,7 @@ async fn test_login_with_sso() { .mount(&server) .await; - let idp = ruma::api::client::session::get_login_types::v3::IdentityProvider::new( + let idp = api::client::session::get_login_types::v3::IdentityProvider::new( "some-id".to_owned(), "idp-name".to_owned(), ); @@ -237,11 +236,10 @@ async fn test_login_error() { if let Some(RumaApiError::ClientApi(api_err)) = err.as_ruma_api_error() { assert_eq!(api_err.status_code, http::StatusCode::from_u16(403).unwrap()); - if let client_api::error::ErrorBody::Standard(StandardErrorBody { - kind, message, .. - }) = &api_err.body + if let api::error::ErrorBody::Standard(StandardErrorBody { kind, message, .. }) = + &api_err.body { - if !matches!(*kind, client_api::error::ErrorKind::Forbidden) { + if !matches!(*kind, api::error::ErrorKind::Forbidden) { panic!("found the wrong `ErrorKind` {kind:?}, expected `Forbidden"); } @@ -281,11 +279,10 @@ async fn test_register_error() { if let Err(err) = client.matrix_auth().register(user).await { if let Some(api_err) = err.as_client_api_error() { assert_eq!(api_err.status_code, http::StatusCode::from_u16(403).unwrap()); - if let client_api::error::ErrorBody::Standard(StandardErrorBody { - kind, message, .. - }) = &api_err.body + if let api::error::ErrorBody::Standard(StandardErrorBody { kind, message, .. }) = + &api_err.body { - if !matches!(*kind, client_api::error::ErrorKind::Forbidden) { + if !matches!(*kind, api::error::ErrorKind::Forbidden) { panic!("found the wrong `ErrorKind` {kind:?}, expected `Forbidden"); } diff --git a/crates/matrix-sdk/tests/integration/refresh_token.rs b/crates/matrix-sdk/tests/integration/refresh_token.rs index f79f3ebdc..96109a579 100644 --- a/crates/matrix-sdk/tests/integration/refresh_token.rs +++ b/crates/matrix-sdk/tests/integration/refresh_token.rs @@ -25,10 +25,8 @@ use matrix_sdk_test::{async_test, test_json}; use ruma::{ api::{ MatrixVersion, - client::{ - account::register, - error::{ErrorKind, UnknownTokenErrorData}, - }, + client::account::register, + error::{ErrorKind, UnknownTokenErrorData}, }, assign, owned_device_id, owned_user_id, };