Change String to &str for all Rocket functions

During setting the latest commit hash for Rocket and updating all the
other crates, there were some messages regarding the usage of `String`
for the Rocket endpoint function calls. I acted upon this message and
changed all `String` types to `&str` and modified the code where needed.

This ended up in less alloc calls, and probably also a bit less memory usage.

- Updated all the crates and commit hashes
- Modified all `String` to `&str` where applicable
This commit is contained in:
BlackDex
2023-04-30 17:18:12 +02:00
parent 951ba55123
commit f906f6230a
16 changed files with 512 additions and 522 deletions

View File

@@ -58,7 +58,7 @@ use crate::{
};
#[put("/devices/identifier/<uuid>/clear-token")]
fn clear_device_token(uuid: String) -> &'static str {
fn clear_device_token(uuid: &str) -> &'static str {
// This endpoint doesn't have auth header
let _ = uuid;
@@ -71,7 +71,7 @@ fn clear_device_token(uuid: String) -> &'static str {
}
#[put("/devices/identifier/<uuid>/token", data = "<data>")]
fn put_device_token(uuid: String, data: JsonUpcase<Value>, headers: Headers) -> Json<Value> {
fn put_device_token(uuid: &str, data: JsonUpcase<Value>, headers: Headers) -> Json<Value> {
let _data: Value = data.into_inner().data;
// Data has a single string value "PushToken"
let _ = uuid;
@@ -170,7 +170,7 @@ async fn put_eq_domains(
}
#[get("/hibp/breach?<username>")]
async fn hibp_breach(username: String) -> JsonResult {
async fn hibp_breach(username: &str) -> JsonResult {
let url = format!(
"https://haveibeenpwned.com/api/v3/breachedaccount/{username}?truncateResponse=false&includeUnverified=false"
);