diff options
author | BlackDex <[email protected]> | 2023-04-30 17:18:12 +0200 |
---|---|---|
committer | BlackDex <[email protected]> | 2023-04-30 17:18:12 +0200 |
commit | f906f6230a8308a3b60d0bac49f99244b7c89df9 (patch) | |
tree | 19aed5a0cbefada1da16eb9d98b39679e43611e4 /src/api/core/folders.rs | |
parent | 951ba5512330d34b633a5e6692935c594b40575a (diff) | |
download | vaultwarden-f906f6230a8308a3b60d0bac49f99244b7c89df9.tar.gz vaultwarden-f906f6230a8308a3b60d0bac49f99244b7c89df9.zip |
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
Diffstat (limited to 'src/api/core/folders.rs')
-rw-r--r-- | src/api/core/folders.rs | 16 |
1 files changed, 8 insertions, 8 deletions
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<Value> { } #[get("/folders/<uuid>")] -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<FolderData>, headers: Headers, mut conn: #[post("/folders/<uuid>", data = "<data>")] async fn post_folder( - uuid: String, + uuid: &str, data: JsonUpcase<FolderData>, headers: Headers, conn: DbConn, @@ -68,7 +68,7 @@ async fn post_folder( #[put("/folders/<uuid>", data = "<data>")] async fn put_folder( - uuid: String, + uuid: &str, data: JsonUpcase<FolderData>, 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/<uuid>/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/<uuid>")] -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"), }; |