From c7fb8baadb16df1106442562e451e48b7293367f Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Wed, 30 Jun 2021 21:05:08 +0200 Subject: [PATCH] Remove useless clones --- src/infra/auth_service.rs | 17 +++++++++++------ src/infra/tcp_api.rs | 5 ++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/infra/auth_service.rs b/src/infra/auth_service.rs index 178b02e..bffb2b6 100644 --- a/src/infra/auth_service.rs +++ b/src/infra/auth_service.rs @@ -175,7 +175,7 @@ where Backend: OpaqueHandler + 'static, { data.backend_handler - .login_start(request.clone()) + .login_start(request.into_inner()) .await .map(|res| ApiResult::Left(web::Json(res))) .unwrap_or_else(error_to_api_response) @@ -225,7 +225,11 @@ async fn opaque_login_finish( where Backend: TcpBackendHandler + BackendHandler + OpaqueHandler + 'static, { - let name = match data.backend_handler.login_finish(request.clone()).await { + let name = match data + .backend_handler + .login_finish(request.into_inner()) + .await + { Ok(n) => n, Err(e) => return error_to_http_response(e), }; @@ -239,10 +243,11 @@ async fn post_authorize( where Backend: TcpBackendHandler + BackendHandler + LoginHandler + 'static, { - if let Err(e) = data.backend_handler.bind(request.clone()).await { + let name = request.name.clone(); + if let Err(e) = data.backend_handler.bind(request.into_inner()).await { return error_to_http_response(e); } - get_login_successful_response(&data, &request.name).await + get_login_successful_response(&data, &name).await } async fn opaque_register_start( @@ -253,7 +258,7 @@ where Backend: OpaqueHandler + 'static, { data.backend_handler - .registration_start(request.clone()) + .registration_start(request.into_inner()) .await .map(|res| ApiResult::Left(web::Json(res))) .unwrap_or_else(error_to_api_response) @@ -268,7 +273,7 @@ where { if let Err(e) = data .backend_handler - .registration_finish(request.clone()) + .registration_finish(request.into_inner()) .await { return error_to_http_response(e); diff --git a/src/infra/tcp_api.rs b/src/infra/tcp_api.rs index 3e59612..97475c3 100644 --- a/src/infra/tcp_api.rs +++ b/src/infra/tcp_api.rs @@ -20,9 +20,8 @@ async fn user_list_handler( where Backend: TcpBackendHandler + BackendHandler + 'static, { - let req: ListUsersRequest = info.clone(); data.backend_handler - .list_users(req) + .list_users(info.into_inner()) .await .map(|res| ApiResult::Left(web::Json(res))) .unwrap_or_else(error_to_api_response) @@ -53,7 +52,7 @@ where Backend: TcpBackendHandler + BackendHandler + 'static, { data.backend_handler - .create_user(info.clone()) + .create_user(info.into_inner()) .await .map(|res| ApiResult::Left(web::Json(res))) .unwrap_or_else(error_to_api_response)