From 0275b1871d1f46d14915e2a71f2165686ffbc56a Mon Sep 17 00:00:00 2001 From: jasonwitty Date: Thu, 21 Aug 2025 13:49:36 -0700 Subject: [PATCH] cargo fmt --- socktop/src/main.rs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/socktop/src/main.rs b/socktop/src/main.rs index aeb308a..94c517f 100644 --- a/socktop/src/main.rs +++ b/socktop/src/main.rs @@ -154,7 +154,9 @@ async fn main() -> Result<(), Box> { ResolveProfile::Loaded(u, t) => (u, t), ResolveProfile::PromptSelect(mut names) => { // Always add demo option to list - if !names.iter().any(|n| n == "demo") { names.push("demo".into()); } + if !names.iter().any(|n| n == "demo") { + names.push("demo".into()); + } eprintln!("Select profile:"); for (i, n) in names.iter().enumerate() { eprintln!(" {}. {}", i + 1, n); @@ -166,7 +168,9 @@ async fn main() -> Result<(), Box> { if let Ok(idx) = line.trim().parse::() { if idx >= 1 && idx <= names.len() { let name = &names[idx - 1]; - if name == "demo" { return run_demo_mode(parsed.tls_ca.as_deref()).await; } + if name == "demo" { + return run_demo_mode(parsed.tls_ca.as_deref()).await; + } if let Some(entry) = profiles_mut.profiles.get(name) { (entry.url.clone(), entry.tls_ca.clone()) } else { @@ -252,7 +256,13 @@ async fn run_demo_mode(_tls_ca: Option<&str>) -> Result<(), Box>>); -impl Drop for DemoGuard { fn drop(&mut self) { if let Some(mut ch) = self.0.lock().unwrap().take() { let _ = ch.kill(); } } } +impl Drop for DemoGuard { + fn drop(&mut self) { + if let Some(mut ch) = self.0.lock().unwrap().take() { + let _ = ch.kill(); + } + } +} fn spawn_demo_agent(port: u16) -> Result> { let candidate = find_agent_executable(); @@ -264,7 +274,9 @@ fn spawn_demo_agent(port: u16) -> Result> let child = cmd.spawn()?; // Give the agent a brief moment to start std::thread::sleep(std::time::Duration::from_millis(300)); - Ok(DemoGuard(std::sync::Arc::new(std::sync::Mutex::new(Some(child))))) + Ok(DemoGuard(std::sync::Arc::new(std::sync::Mutex::new(Some( + child, + ))))) } fn find_agent_executable() -> std::path::PathBuf { @@ -276,7 +288,9 @@ fn find_agent_executable() -> std::path::PathBuf { #[cfg(not(windows))] let name = "socktop_agent"; let candidate = parent.join(name); - if candidate.exists() { return candidate; } + if candidate.exists() { + return candidate; + } } } // Fallback to relying on PATH