From ab3f22c212264ccc744f4168ce150efb717552d3 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Fri, 16 May 2025 12:22:20 +0200 Subject: [PATCH] refactor(sdk): Reduce the output size of `get_header`. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch reduces the size of the output's `Result::Err` variant of `get_header` from 160 bytes to 8 bytes. --- .../src/authentication/oauth/qrcode/rendezvous_channel.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/matrix-sdk/src/authentication/oauth/qrcode/rendezvous_channel.rs b/crates/matrix-sdk/src/authentication/oauth/qrcode/rendezvous_channel.rs index 57fe9981a..66bbd2fee 100644 --- a/crates/matrix-sdk/src/authentication/oauth/qrcode/rendezvous_channel.rs +++ b/crates/matrix-sdk/src/authentication/oauth/qrcode/rendezvous_channel.rs @@ -39,12 +39,14 @@ type Etag = String; fn get_header( header_map: &HeaderMap, header_name: &HeaderName, -) -> Result> { +) -> Result>> { let header = header_map .get(header_name) - .ok_or(HeaderDeserializationError::MissingHeader(ETAG.to_string()))?; + .ok_or(HeaderDeserializationError::MissingHeader(ETAG.to_string())) + .map_err(|error| Box::new(FromHttpResponseError::from(error)))?; - let header = header.to_str()?.to_owned(); + let header = + header.to_str().map_err(|error| Box::new(FromHttpResponseError::from(error)))?.to_owned(); Ok(header) }