]> git.proxmox.com Git - proxmox.git/commitdiff
http: clippy fixups
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 20 Jul 2022 11:31:58 +0000 (13:31 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 20 Jul 2022 11:31:58 +0000 (13:31 +0200)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
proxmox-http/src/client/connector.rs
proxmox-http/src/client/rate_limited_stream.rs

index a01dbca46eb1478e04576ae6b593d5a53d3d6677..d6ba9dd2a67b45a3cf177de15166ea4053e7652b 100644 (file)
@@ -170,6 +170,7 @@ impl hyper::service::Service<Uri> for HttpsConnector {
 
             if use_connect {
                 async move {
+                    use std::fmt::Write as _;
                     let tcp_stream = connector.call(proxy_uri).await.map_err(|err| {
                         format_err!("error connecting to {} - {}", proxy_authority, err)
                     })?;
@@ -181,10 +182,13 @@ impl hyper::service::Service<Uri> for HttpsConnector {
 
                     let mut connect_request = format!("CONNECT {0}:{1} HTTP/1.1\r\n", host, port);
                     if let Some(authorization) = authorization {
-                        connect_request
-                            .push_str(&format!("Proxy-Authorization: {}\r\n", authorization));
+                        let _ = write!(
+                            connect_request,
+                            "Proxy-Authorization: {}\r\n",
+                            authorization
+                        );
                     }
-                    connect_request.push_str(&format!("Host: {0}:{1}\r\n\r\n", host, port));
+                    let _ = write!(connect_request, "Host: {0}:{1}\r\n\r\n", host, port);
 
                     tcp_stream.write_all(connect_request.as_bytes()).await?;
                     tcp_stream.flush().await?;
index 8fd07a34b16e6dc329c4a8cd9d07111e0ea9b192..0fbc559a696e9c60dc3e4a653ccab8f40e872cc6 100644 (file)
@@ -15,14 +15,16 @@ use super::{RateLimiter, ShareableRateLimit};
 
 type SharedRateLimit = Arc<dyn ShareableRateLimit>;
 
+pub type RateLimiterCallback =
+    dyn Fn() -> (Option<SharedRateLimit>, Option<SharedRateLimit>) + Send;
+
 /// A rate limited stream using [RateLimiter]
 pub struct RateLimitedStream<S> {
     read_limiter: Option<SharedRateLimit>,
     read_delay: Option<Pin<Box<Sleep>>>,
     write_limiter: Option<SharedRateLimit>,
     write_delay: Option<Pin<Box<Sleep>>>,
-    update_limiter_cb:
-        Option<Box<dyn Fn() -> (Option<SharedRateLimit>, Option<SharedRateLimit>) + Send>>,
+    update_limiter_cb: Option<Box<RateLimiterCallback>>,
     last_limiter_update: Instant,
     stream: S,
 }