From f906f6230a8308a3b60d0bac49f99244b7c89df9 Mon Sep 17 00:00:00 2001 From: BlackDex Date: Sun, 30 Apr 2023 17:18:12 +0200 Subject: 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 --- src/api/core/folders.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/api/core/folders.rs') diff --git a/src/api/core/folders.rs b/src/api/core/folders.rs index c27d5455..7b52bd18 100644 --- a/src/api/core/folders.rs +++ b/src/api/core/folders.rs @@ -24,8 +24,8 @@ async fn get_folders(headers: Headers, mut conn: DbConn) -> Json { } #[get("/folders/")] -async fn get_folder(uuid: String, headers: Headers, mut conn: DbConn) -> JsonResult { - let folder = match Folder::find_by_uuid(&uuid, &mut conn).await { +async fn get_folder(uuid: &str, headers: Headers, mut conn: DbConn) -> JsonResult { + let folder = match Folder::find_by_uuid(uuid, &mut conn).await { Some(folder) => folder, _ => err!("Invalid folder"), }; @@ -57,7 +57,7 @@ async fn post_folders(data: JsonUpcase, headers: Headers, mut conn: #[post("/folders/", data = "")] async fn post_folder( - uuid: String, + uuid: &str, data: JsonUpcase, headers: Headers, conn: DbConn, @@ -68,7 +68,7 @@ async fn post_folder( #[put("/folders/", data = "")] async fn put_folder( - uuid: String, + uuid: &str, data: JsonUpcase, headers: Headers, mut conn: DbConn, @@ -76,7 +76,7 @@ async fn put_folder( ) -> JsonResult { let data: FolderData = data.into_inner().data; - let mut folder = match Folder::find_by_uuid(&uuid, &mut conn).await { + let mut folder = match Folder::find_by_uuid(uuid, &mut conn).await { Some(folder) => folder, _ => err!("Invalid folder"), }; @@ -94,13 +94,13 @@ async fn put_folder( } #[post("/folders//delete")] -async fn delete_folder_post(uuid: String, headers: Headers, conn: DbConn, nt: Notify<'_>) -> EmptyResult { +async fn delete_folder_post(uuid: &str, headers: Headers, conn: DbConn, nt: Notify<'_>) -> EmptyResult { delete_folder(uuid, headers, conn, nt).await } #[delete("/folders/")] -async fn delete_folder(uuid: String, headers: Headers, mut conn: DbConn, nt: Notify<'_>) -> EmptyResult { - let folder = match Folder::find_by_uuid(&uuid, &mut conn).await { +async fn delete_folder(uuid: &str, headers: Headers, mut conn: DbConn, nt: Notify<'_>) -> EmptyResult { + let folder = match Folder::find_by_uuid(uuid, &mut conn).await { Some(folder) => folder, _ => err!("Invalid folder"), }; -- cgit v1.2.3