From c656ad406846ad7e16005682e8f6e7efbbf2d301 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Thu, 13 Jun 2024 17:28:10 +0200 Subject: [PATCH] sdk: prefer direct use of `IntoHttp` ctor instead of implicit `#[from]` conversions --- .../src/authentication/qrcode/rendezvous_channel.rs | 2 +- crates/matrix-sdk/src/error.rs | 2 +- crates/matrix-sdk/src/http_client/mod.rs | 5 +++-- crates/matrix-sdk/src/matrix_auth/mod.rs | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/matrix-sdk/src/authentication/qrcode/rendezvous_channel.rs b/crates/matrix-sdk/src/authentication/qrcode/rendezvous_channel.rs index bee384f5921..7ee5c66a584 100644 --- a/crates/matrix-sdk/src/authentication/qrcode/rendezvous_channel.rs +++ b/crates/matrix-sdk/src/authentication/qrcode/rendezvous_channel.rs @@ -96,7 +96,7 @@ fn response_to_error(status: StatusCode, body: Vec) -> HttpError { error.into() } - Err(e) => e.into(), + Err(e) => HttpError::IntoHttp(e), } } diff --git a/crates/matrix-sdk/src/error.rs b/crates/matrix-sdk/src/error.rs index 172ab3a08c8..43c0da44be0 100644 --- a/crates/matrix-sdk/src/error.rs +++ b/crates/matrix-sdk/src/error.rs @@ -98,7 +98,7 @@ pub enum HttpError { /// An error converting between ruma_client_api types and Hyper types. #[error(transparent)] - IntoHttp(#[from] IntoHttpError), + IntoHttp(IntoHttpError), /// An error occurred while refreshing the access token. #[error(transparent)] diff --git a/crates/matrix-sdk/src/http_client/mod.rs b/crates/matrix-sdk/src/http_client/mod.rs index 6a8a01d1d84..3b2a699b966 100644 --- a/crates/matrix-sdk/src/http_client/mod.rs +++ b/crates/matrix-sdk/src/http_client/mod.rs @@ -150,8 +150,9 @@ impl HttpClient { } } - let request = - self.serialize_request(request, config, homeserver, access_token, server_versions)?; + let request = self + .serialize_request(request, config, homeserver, access_token, server_versions) + .map_err(HttpError::IntoHttp)?; let method = request.method(); diff --git a/crates/matrix-sdk/src/matrix_auth/mod.rs b/crates/matrix-sdk/src/matrix_auth/mod.rs index 9f07f41e2c3..55699192d76 100644 --- a/crates/matrix-sdk/src/matrix_auth/mod.rs +++ b/crates/matrix-sdk/src/matrix_auth/mod.rs @@ -132,7 +132,7 @@ impl MatrixAuth { match request { Ok(req) => Ok(req.uri().to_string()), - Err(err) => Err(Error::from(HttpError::from(err))), + Err(err) => Err(Error::from(HttpError::IntoHttp(err))), } }