@@ -138,19 +138,19 @@ fn sort_connections(
138138 a_process. cmp ( b_process)
139139 }
140140
141- SortColumn :: LocalAddress => {
142- a. local_addr . to_string ( ) . cmp ( & b. local_addr . to_string ( ) )
143- }
141+ SortColumn :: LocalAddress => a. local_addr . to_string ( ) . cmp ( & b. local_addr . to_string ( ) ) ,
144142
145- SortColumn :: RemoteAddress => {
146- a. remote_addr . to_string ( ) . cmp ( & b. remote_addr . to_string ( ) )
147- }
143+ SortColumn :: RemoteAddress => a. remote_addr . to_string ( ) . cmp ( & b. remote_addr . to_string ( ) ) ,
148144
149145 SortColumn :: Application => {
150- let a_app = a. dpi_info . as_ref ( )
146+ let a_app = a
147+ . dpi_info
148+ . as_ref ( )
151149 . map ( |dpi| dpi. application . to_string ( ) )
152150 . unwrap_or_default ( ) ;
153- let b_app = b. dpi_info . as_ref ( )
151+ let b_app = b
152+ . dpi_info
153+ . as_ref ( )
154154 . map ( |dpi| dpi. application . to_string ( ) )
155155 . unwrap_or_default ( ) ;
156156 a_app. cmp ( & b_app)
@@ -162,13 +162,9 @@ fn sort_connections(
162162 a_service. cmp ( b_service)
163163 }
164164
165- SortColumn :: State => {
166- a. state ( ) . cmp ( & b. state ( ) )
167- }
165+ SortColumn :: State => a. state ( ) . cmp ( & b. state ( ) ) ,
168166
169- SortColumn :: Protocol => {
170- a. protocol . to_string ( ) . cmp ( & b. protocol . to_string ( ) )
171- }
167+ SortColumn :: Protocol => a. protocol . to_string ( ) . cmp ( & b. protocol . to_string ( ) ) ,
172168 } ;
173169
174170 if ascending {
@@ -199,7 +195,11 @@ fn run_ui_loop<B: ratatui::prelude::Backend>(
199195
200196 // Apply sorting (after filtering)
201197 // This sorted list MUST be used for all operations (display + navigation)
202- sort_connections ( & mut connections, ui_state. sort_column , ui_state. sort_ascending ) ;
198+ sort_connections (
199+ & mut connections,
200+ ui_state. sort_column ,
201+ ui_state. sort_ascending ,
202+ ) ;
203203
204204 let stats = app. get_stats ( ) ;
205205
@@ -393,10 +393,7 @@ fn run_ui_loop<B: ratatui::prelude::Backend>(
393393 ui_state. quit_confirmation = false ;
394394 // Use the SAME sorted connections list from the main loop
395395 // to ensure index consistency with the displayed table
396- debug ! (
397- "Navigation UP: {} connections available" ,
398- connections. len( )
399- ) ;
396+ debug ! ( "Navigation UP: {} connections available" , connections. len( ) ) ;
400397 ui_state. move_selection_up ( & connections) ;
401398 }
402399
@@ -468,7 +465,11 @@ fn run_ui_loop<B: ratatui::prelude::Backend>(
468465 info ! (
469466 "Sort column: {} ({})" ,
470467 ui_state. sort_column. display_name( ) ,
471- if ui_state. sort_ascending { "ascending" } else { "descending" }
468+ if ui_state. sort_ascending {
469+ "ascending"
470+ } else {
471+ "descending"
472+ }
472473 ) ;
473474 }
474475
@@ -478,7 +479,11 @@ fn run_ui_loop<B: ratatui::prelude::Backend>(
478479 ui_state. toggle_sort_direction ( ) ;
479480 info ! (
480481 "Sort direction: {} ({})" ,
481- if ui_state. sort_ascending { "ascending" } else { "descending" } ,
482+ if ui_state. sort_ascending {
483+ "ascending"
484+ } else {
485+ "descending"
486+ } ,
482487 ui_state. sort_column. display_name( )
483488 ) ;
484489 }
@@ -547,13 +552,21 @@ fn check_privileges_early() -> Result<()> {
547552 match network:: privileges:: check_packet_capture_privileges ( ) {
548553 Ok ( status) if !status. has_privileges => {
549554 // Print error to stderr before TUI starts
550- eprintln ! ( "\n ╔═══════════════════════════════════════════════════════════════════════════╗" ) ;
551- eprintln ! ( "║ INSUFFICIENT PRIVILEGES ║" ) ;
552- eprintln ! ( "╚═══════════════════════════════════════════════════════════════════════════╝" ) ;
555+ eprintln ! (
556+ "\n ╔═══════════════════════════════════════════════════════════════════════════╗"
557+ ) ;
558+ eprintln ! (
559+ "║ INSUFFICIENT PRIVILEGES ║"
560+ ) ;
561+ eprintln ! (
562+ "╚═══════════════════════════════════════════════════════════════════════════╝"
563+ ) ;
553564 eprintln ! ( ) ;
554565 eprintln ! ( "{}" , status. error_message( ) ) ;
555566
556- return Err ( anyhow:: anyhow!( "Insufficient privileges for packet capture" ) ) ;
567+ return Err ( anyhow:: anyhow!(
568+ "Insufficient privileges for packet capture"
569+ ) ) ;
557570 }
558571 Err ( e) => {
559572 // Privilege check failed - warn but continue
@@ -578,7 +591,9 @@ fn check_windows_dependencies() -> Result<()> {
578591 let packet_available = check_dll_available ( "Packet.dll" ) ;
579592
580593 if !wpcap_available || !packet_available {
581- eprintln ! ( "\n ╔═══════════════════════════════════════════════════════════════════════════╗" ) ;
594+ eprintln ! (
595+ "\n ╔═══════════════════════════════════════════════════════════════════════════╗"
596+ ) ;
582597 eprintln ! ( "║ MISSING DEPENDENCY ║" ) ;
583598 eprintln ! ( "╚═══════════════════════════════════════════════════════════════════════════╝" ) ;
584599 eprintln ! ( ) ;
@@ -603,7 +618,9 @@ fn check_windows_dependencies() -> Result<()> {
603618 eprintln ! ( "After installation, restart your terminal and try again." ) ;
604619 eprintln ! ( ) ;
605620
606- return Err ( anyhow ! ( "Npcap is not installed or not in WinPcap compatible mode" ) ) ;
621+ return Err ( anyhow ! (
622+ "Npcap is not installed or not in WinPcap compatible mode"
623+ ) ) ;
607624 }
608625
609626 Ok ( ( ) )
@@ -626,7 +643,9 @@ fn check_dll_available(dll_name: &str) -> bool {
626643 // Use LoadLibraryA to check if the DLL can be loaded
627644 let handle = LoadLibraryA ( PCSTR ( dll_cstring. as_ptr ( ) as * const u8 ) ) ;
628645
629- if let Ok ( h) = handle && h != HMODULE ( std:: ptr:: null_mut ( ) ) {
646+ if let Ok ( h) = handle
647+ && h != HMODULE ( std:: ptr:: null_mut ( ) )
648+ {
630649 // Free the library if it was loaded
631650 let _ = FreeLibrary ( h) ;
632651 true
0 commit comments