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 015131FF15C
	for <inbox@lore.proxmox.com>; Wed, 19 Feb 2025 15:07:10 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id BB2E52AA8B;
	Wed, 19 Feb 2025 15:07:05 +0100 (CET)
From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pdm-devel@lists.proxmox.com
Date: Wed, 19 Feb 2025 15:06:30 +0100
Message-Id: <20250219140630.368105-1-m.sandoval@proxmox.com>
X-Mailer: git-send-email 2.39.5
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.104 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. [schema2rust.pm]
Subject: [pdm-devel] [PATCH proxmox-api-types] generator: Remove needless
 borrows
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>

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 pve-api-types/generator-lib/Schema2Rust.pm | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/pve-api-types/generator-lib/Schema2Rust.pm b/pve-api-types/generator-lib/Schema2Rust.pm
index 84f36f6..173d66f 100644
--- a/pve-api-types/generator-lib/Schema2Rust.pm
+++ b/pve-api-types/generator-lib/Schema2Rust.pm
@@ -453,6 +453,7 @@ my sub print_method_without_body : prototype($$$$$) {
     }
 
     my $input;
+    my $is_url_owned = 0;
     if (defined($input = $def->{input_type})) {
         print {$out} "    params: $input,\n";
         print {$out} ") -> Result<$def->{output_type}, Error> {\n";
@@ -486,6 +487,7 @@ my sub print_method_without_body : prototype($$$$$) {
                 print {$out} "    add_query_arg(&mut query, &mut sep, \"$name\", &p_$rust_name);\n";
             }
         }
+        $is_url_owned = 1;
         print {$out} "    let url = format!(\"/api2/extjs$def->{url}\{query}\");\n";
     } elsif (defined($input = $def->{input})) {
         for my $arg ($input->@*) {
@@ -510,6 +512,7 @@ my sub print_method_without_body : prototype($$$$$) {
                     print {$out} "    add_query_arg(&mut query, &mut sep, \"$name\", &$rust_name);\n";
                 }
             }
+            $is_url_owned = 1;
             print {$out} "    let url = format!(\"/api2/extjs$def->{url}\{query}\");\n";
         } else {
             print {$out} "    let url = \"/api2/extjs$def->{url}\";\n";
@@ -523,7 +526,8 @@ my sub print_method_without_body : prototype($$$$$) {
         print {$out} "    let url = \"/api2/extjs$def->{url}\";\n";
     }
 
-    my $call = return_expr($def, "self.0.$method(&url).await?");
+    my $maybe_borrowed_url = $is_url_owned ? '&url' : 'url';
+    my $call = return_expr($def, "self.0.$method($maybe_borrowed_url).await?");
     print {$out} "    $call\n";
 
     print {$out} "}\n\n";
@@ -554,7 +558,7 @@ my sub print_method_with_body : prototype($$$$$) {
     }
     # print {$out} "    // self.login().await?;\n";
     print {$out} "    let url = \"/api2/extjs$def->{url}\";\n";
-        my $call = return_expr($def, "self.0.${method}(&url, &params).await?");
+        my $call = return_expr($def, "self.0.${method}(url, &params).await?");
         print {$out} "    $call\n";
     print {$out} "}\n\n";
 }
-- 
2.39.5



_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel