From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pdm-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id D24851FF168 for <inbox@lore.proxmox.com>; Tue, 4 Mar 2025 13:05:49 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 609651DA86; Tue, 4 Mar 2025 13:05:46 +0100 (CET) From: Shannon Sterz <s.sterz@proxmox.com> To: pdm-devel@lists.proxmox.com Date: Tue, 4 Mar 2025 13:04:47 +0100 Message-Id: <20250304120506.135617-3-s.sterz@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250304120506.135617-1-s.sterz@proxmox.com> References: <20250304120506.135617-1-s.sterz@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.025 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [rest.rs] Subject: [pdm-devel] [PATCH proxmox v4 02/21] rest-server: borrow parts parameter in `get_request_parameter` X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion <pdm-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pdm-devel>, <mailto:pdm-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pdm-devel/> List-Post: <mailto:pdm-devel@lists.proxmox.com> List-Help: <mailto:pdm-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel>, <mailto:pdm-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox Datacenter Manager development discussion <pdm-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" <pdm-devel-bounces@lists.proxmox.com> this function does not require ownership of the parts parameter, so we can simply borrow it. this way we can pass the parameter on to a handler that consumes them even when using `get_request_parameter` Signed-off-by: Shannon Sterz <s.sterz@proxmox.com> --- proxmox-rest-server/src/rest.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/proxmox-rest-server/src/rest.rs b/proxmox-rest-server/src/rest.rs index d23ed776..78339b75 100644 --- a/proxmox-rest-server/src/rest.rs +++ b/proxmox-rest-server/src/rest.rs @@ -383,7 +383,7 @@ fn parse_query_parameters<S: 'static + BuildHasher + Send>( async fn get_request_parameters<S: 'static + BuildHasher + Send>( param_schema: ParameterSchema, - parts: Parts, + parts: &Parts, req_body: Body, uri_param: HashMap<String, String, S>, ) -> Result<Value, Error> { @@ -433,7 +433,7 @@ async fn get_request_parameters<S: 'static + BuildHasher + Send>( param_schema.verify_json(¶ms)?; Ok(params) } else { - parse_query_parameters(param_schema, utf8_data, &parts, &uri_param) + parse_query_parameters(param_schema, utf8_data, parts, &uri_param) } } @@ -548,7 +548,7 @@ pub(crate) async fn handle_api_request<Env: RpcEnvironment, S: 'static + BuildHa } ApiHandler::StreamSync(handler) => { let params = - get_request_parameters(info.parameters, parts, req_body, uri_param).await?; + get_request_parameters(info.parameters, &parts, req_body, uri_param).await?; match (handler)(params, info, &mut rpcenv) { Ok(iter) if accept_json_seq => handle_sync_stream_as_json_seq(iter), Ok(iter) => iter @@ -559,7 +559,7 @@ pub(crate) async fn handle_api_request<Env: RpcEnvironment, S: 'static + BuildHa } ApiHandler::StreamAsync(handler) => { let params = - get_request_parameters(info.parameters, parts, req_body, uri_param).await?; + get_request_parameters(info.parameters, &parts, req_body, uri_param).await?; match (handler)(params, info, &mut rpcenv).await { Ok(stream) if accept_json_seq => handle_stream_as_json_seq(stream), Ok(stream) => stream @@ -571,25 +571,25 @@ pub(crate) async fn handle_api_request<Env: RpcEnvironment, S: 'static + BuildHa } ApiHandler::SerializingSync(handler) => { let params = - get_request_parameters(info.parameters, parts, req_body, uri_param).await?; + get_request_parameters(info.parameters, &parts, req_body, uri_param).await?; (handler)(params, info, &mut rpcenv) .and_then(|data| formatter.format_data_streaming(data, &rpcenv)) } ApiHandler::SerializingAsync(handler) => { let params = - get_request_parameters(info.parameters, parts, req_body, uri_param).await?; + get_request_parameters(info.parameters, &parts, req_body, uri_param).await?; (handler)(params, info, &mut rpcenv) .await .and_then(|data| formatter.format_data_streaming(data, &rpcenv)) } ApiHandler::Sync(handler) => { let params = - get_request_parameters(info.parameters, parts, req_body, uri_param).await?; + get_request_parameters(info.parameters, &parts, req_body, uri_param).await?; (handler)(params, info, &mut rpcenv).map(|data| formatter.format_data(data, &rpcenv)) } ApiHandler::Async(handler) => { let params = - get_request_parameters(info.parameters, parts, req_body, uri_param).await?; + get_request_parameters(info.parameters, &parts, req_body, uri_param).await?; (handler)(params, info, &mut rpcenv) .await .map(|data| formatter.format_data(data, &rpcenv)) -- 2.39.5 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel