Explorar o código

chore: make clippy happy

Yujia Qiao %!s(int64=3) %!d(string=hai) anos
pai
achega
d2c55cc99c
Modificáronse 5 ficheiros con 7 adicións e 7 borrados
  1. 1 1
      src/client.rs
  2. 3 3
      src/config.rs
  3. 1 1
      src/helper.rs
  4. 1 1
      src/server.rs
  5. 1 1
      src/transport/tls.rs

+ 1 - 1
src/client.rs

@@ -33,7 +33,7 @@ pub async fn run_client(
     shutdown_rx: broadcast::Receiver<bool>,
     service_rx: mpsc::Receiver<ServiceChange>,
 ) -> Result<()> {
-    let config = config.client.ok_or(anyhow!(
+    let config = config.client.ok_or_else(|| anyhow!(
         "Try to run as a client, but the configuration is missing. Please add the `[client]` block"
     ))?;
 

+ 3 - 3
src/config.rs

@@ -289,18 +289,18 @@ impl Config {
                 let tls_config = config
                     .tls
                     .as_ref()
-                    .ok_or(anyhow!("Missing TLS configuration"))?;
+                    .ok_or_else(|| anyhow!("Missing TLS configuration"))?;
                 if is_server {
                     tls_config
                         .pkcs12
                         .as_ref()
                         .and(tls_config.pkcs12_password.as_ref())
-                        .ok_or(anyhow!("Missing `pkcs12` or `pkcs12_password`"))?;
+                        .ok_or_else(|| anyhow!("Missing `pkcs12` or `pkcs12_password`"))?;
                 } else {
                     tls_config
                         .trusted_root
                         .as_ref()
-                        .ok_or(anyhow!("Missing `trusted_root`"))?;
+                        .ok_or_else(|| anyhow!("Missing `trusted_root`"))?;
                 }
                 Ok(())
             }

+ 1 - 1
src/helper.rs

@@ -44,7 +44,7 @@ async fn to_socket_addr<A: ToSocketAddrs>(addr: A) -> Result<SocketAddr> {
     lookup_host(addr)
         .await?
         .next()
-        .ok_or(anyhow!("Failed to lookup the host"))
+        .ok_or_else(|| anyhow!("Failed to lookup the host"))
 }
 
 pub fn host_port_pair(s: &str) -> Result<(&str, u16)> {

+ 1 - 1
src/server.rs

@@ -676,7 +676,7 @@ async fn run_udp_connection_pool<T: Transport>(
     let mut conn = data_ch_rx
         .recv()
         .await
-        .ok_or(anyhow!("No available data channels"))?;
+        .ok_or_else(|| anyhow!("No available data channels"))?;
     conn.write_all(&cmd).await?;
 
     let mut buf = [0u8; UDP_BUFFER_SIZE];

+ 1 - 1
src/transport/tls.rs

@@ -26,7 +26,7 @@ impl Transport for TlsTransport {
 
     fn new(config: &TransportConfig) -> Result<Self> {
         let tcp = TcpTransport::new(config)?;
-        let config = config.tls.as_ref().ok_or(anyhow!("Missing tls config"))?;
+        let config = config.tls.as_ref().ok_or_else(|| anyhow!("Missing tls config"))?;
 
         let connector = match config.trusted_root.as_ref() {
             Some(path) => {