fix: remove unneeded string conversions

This commit is contained in:
Radical 2025-05-20 02:01:49 +02:00
parent f9c48db175
commit f3f3478ae0

View file

@ -144,9 +144,9 @@ impl<'a> Storage {
.await?; .await?;
if response.status().as_u16() == 401 { if response.status().as_u16() == 401 {
return Err(Error::Authentication(String::from(response.text().await?))) return Err(Error::Authentication(response.text().await?))
} else if response.status().as_u16() == 400 { } else if response.status().as_u16() == 400 {
return Err(Error::BadRequest(String::from(response.text().await?))) return Err(Error::BadRequest(response.text().await?))
} }
Ok(()) Ok(())
@ -181,9 +181,9 @@ impl<'a> Storage {
.await?; .await?;
if response.status().as_u16() == 401 { if response.status().as_u16() == 401 {
return Err(Error::Authentication(String::from(response.text().await?))) return Err(Error::Authentication(response.text().await?))
} else if response.status().as_u16() == 404 { } else if response.status().as_u16() == 404 {
return Err(Error::NotFound(String::from(response.text().await?))) return Err(Error::NotFound(response.text().await?))
} }
Ok(response.bytes().await?) Ok(response.bytes().await?)
@ -212,9 +212,9 @@ impl<'a> Storage {
.await?; .await?;
if response.status().as_u16() == 401 { if response.status().as_u16() == 401 {
return Err(Error::Authentication(String::from(response.text().await?))) return Err(Error::Authentication(response.text().await?))
} else if response.status().as_u16() == 400 { } else if response.status().as_u16() == 400 {
return Err(Error::BadRequest(String::from(response.text().await?))) return Err(Error::BadRequest(response.text().await?))
} }
Ok(()) Ok(())
@ -245,9 +245,9 @@ impl<'a> Storage {
.await?; .await?;
if response.status().as_u16() == 401 { if response.status().as_u16() == 401 {
return Err(Error::Authentication(String::from(response.text().await?))) return Err(Error::Authentication(response.text().await?))
} else if response.status().as_u16() == 400 { } else if response.status().as_u16() == 400 {
return Err(Error::BadRequest(String::from(response.text().await?))) return Err(Error::BadRequest(response.text().await?))
} }
Ok(response.json().await?) Ok(response.json().await?)