refactor(sdk): Reduce the output size of get_header.

This patch reduces the size of the output's `Result::Err` variant of
`get_header` from 160 bytes to 8 bytes.
This commit is contained in:
Ivan Enderlin
2025-05-16 12:22:20 +02:00
parent e41dbd6300
commit ab3f22c212

View File

@@ -39,12 +39,14 @@ type Etag = String;
fn get_header(
header_map: &HeaderMap,
header_name: &HeaderName,
) -> Result<String, FromHttpResponseError<RumaApiError>> {
) -> Result<String, Box<FromHttpResponseError<RumaApiError>>> {
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)
}