From 08a2cdb1d0685beb223c054058cd2c03ffe196ec Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Thu, 27 Nov 2025 15:27:07 +0100 Subject: [PATCH] Reformat Signed-off-by: Otto Moerbeek --- .../recursordist/rec-rust-lib/rust/src/web.rs | 57 ++++++------------- 1 file changed, 18 insertions(+), 39 deletions(-) diff --git a/pdns/recursordist/rec-rust-lib/rust/src/web.rs b/pdns/recursordist/rec-rust-lib/rust/src/web.rs index eafa91d756..7029590239 100644 --- a/pdns/recursordist/rec-rust-lib/rust/src/web.rs +++ b/pdns/recursordist/rec-rust-lib/rust/src/web.rs @@ -93,10 +93,7 @@ fn unauthorized(response: &mut rustweb::Response, headers: &mut header::HeaderMa response.status = status.as_u16(); let val = format!("{} realm=\"PowerDNS\"", auth); if let Ok(data) = header::HeaderValue::from_str(&val) { - headers.insert( - header::WWW_AUTHENTICATE, - data, - ); + headers.insert(header::WWW_AUTHENTICATE, data); } if let Some(body) = status.canonical_reason() { response.body = body.as_bytes().to_vec(); @@ -295,12 +292,7 @@ struct Context { } // Serve a file -fn file( - method: &Method, - path: &str, - request: &rustweb::Request, - response: &mut rustweb::Response, -) { +fn file(method: &Method, path: &str, request: &rustweb::Request, response: &mut rustweb::Response) { // This calls into C++ if rustweb::serveStuff(request, response).is_err() { // Return 404 not found response. @@ -324,12 +316,8 @@ fn file( } } -type FileFunc = fn( - method: &Method, - path: &str, - request: &rustweb::Request, - response: &mut rustweb::Response, -); +type FileFunc = + fn(method: &Method, path: &str, request: &rustweb::Request, response: &mut rustweb::Response); // Match a request and return the function that implements it, this should probably be table based. fn matcher( @@ -680,18 +668,15 @@ async fn process_request( for kv in response.headers { if let Ok(key) = header::HeaderName::from_bytes(kv.key.as_bytes()) { if let Ok(value) = header::HeaderValue::from_str(kv.value.as_str()) { - rust_response.headers_mut().insert( - key, value - ); + rust_response.headers_mut().insert(key, value); } } } if let Ok(close) = header::HeaderValue::from_str("close") { - rust_response.headers_mut().insert( - header::CONNECTION, - close - ); + rust_response + .headers_mut() + .insert(header::CONNECTION, close); } if ctx.loglevel != rustmisc::LogLevel::None { let version = format!("{:?}", version); @@ -972,7 +957,7 @@ pub fn serveweb( while let Some(res) = set.join_next().await { let msg = match res { Ok(Err(wrapped)) => format!("{:?}", wrapped), - _ => format!("{:?}", res) + _ => format!("{:?}", res), }; rustmisc::error( &ctx.logger, @@ -990,11 +975,8 @@ pub fn serveweb( // Load public certificate from file. fn load_certs(filename: &str) -> std::io::Result>> { // Open certificate file. - let certfile = std::fs::File::open(filename).map_err(|e| { - std::io::Error::other( - format!("Failed to open {}: {}", filename, e), - ) - })?; + let certfile = std::fs::File::open(filename) + .map_err(|e| std::io::Error::other(format!("Failed to open {}: {}", filename, e)))?; let mut reader = std::io::BufReader::new(certfile); // Load and return certificate. @@ -1004,21 +986,18 @@ fn load_certs(filename: &str) -> std::io::Result std::io::Result> { // Open keyfile. - let keyfile = std::fs::File::open(filename).map_err(|e| { - std::io::Error::other( - format!("Failed to open {}: {}", filename, e), - ) - })?; + let keyfile = std::fs::File::open(filename) + .map_err(|e| std::io::Error::other(format!("Failed to open {}: {}", filename, e)))?; let mut reader = std::io::BufReader::new(keyfile); // Load and return a single private key. match rustls_pemfile::private_key(&mut reader) { Ok(Some(pkey)) => Ok(pkey), - Ok(None) => Err( - std::io::Error::other( - format!("Failed to parse private key from {}", filename), - )), - Err(e) => Err(e) + Ok(None) => Err(std::io::Error::other(format!( + "Failed to parse private key from {}", + filename + ))), + Err(e) => Err(e), } } -- 2.47.3