From 8eafae44d9de359737d2a35c7002c3daeb6cffba Mon Sep 17 00:00:00 2001 From: GyulyVGC Date: Sat, 21 Sep 2024 16:05:19 +0200 Subject: [PATCH] fixing overview page lifetimes --- src/gui/pages/inspect_page.rs | 4 +-- src/gui/pages/overview_page.rs | 50 ++++++++++++++++++---------------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/gui/pages/inspect_page.rs b/src/gui/pages/inspect_page.rs index ca91bf03..b8c77e55 100644 --- a/src/gui/pages/inspect_page.rs +++ b/src/gui/pages/inspect_page.rs @@ -34,7 +34,7 @@ use crate::utils::types::icon::Icon; use crate::{ConfigSettings, Language, ReportSortType, RunningPage, Sniffer, StyleType}; /// Computes the body of gui inspect page -pub fn inspect_page<'a>(sniffer: &Sniffer) -> Container<'a, Message, StyleType> { +pub fn inspect_page(sniffer: &Sniffer) -> Container { let ConfigSettings { style, language, .. } = sniffer.configs.lock().unwrap().settings; @@ -103,7 +103,7 @@ pub fn inspect_page<'a>(sniffer: &Sniffer) -> Container<'a, Message, StyleType> Container::new(Column::new().push(tab_and_body.push(body))).height(Length::Fill) } -fn lazy_report(sniffer: &Sniffer) -> Column { +fn lazy_report(sniffer: &Sniffer) -> Column<'static, Message, StyleType> { let ConfigSettings { style, language, .. } = sniffer.configs.lock().unwrap().settings; diff --git a/src/gui/pages/overview_page.rs b/src/gui/pages/overview_page.rs index 476cf183..0bc7ec97 100644 --- a/src/gui/pages/overview_page.rs +++ b/src/gui/pages/overview_page.rs @@ -48,7 +48,7 @@ use crate::utils::types::icon::Icon; use crate::{ByteMultiple, ChartType, ConfigSettings, Language, RunningPage, StyleType}; /// Computes the body of gui overview page -pub fn overview_page<'a>(sniffer: &'a Sniffer) -> Container<'a, Message, StyleType> { +pub fn overview_page(sniffer: &Sniffer) -> Container { let ConfigSettings { style, language, .. } = sniffer.configs.lock().unwrap().settings; @@ -141,12 +141,12 @@ pub fn overview_page<'a>(sniffer: &'a Sniffer) -> Container<'a, Message, StyleTy Container::new(Column::new().push(tab_and_body.push(body))).height(Length::Fill) } -fn body_no_packets<'a>( +fn body_no_packets( device: &MyDevice, font: Font, language: Language, waiting: &str, -) -> Column<'a, Message, StyleType> { +) -> Column<'static, Message, StyleType> { let link_type = device.link_type; let mut adapter_info = device.name.clone(); adapter_info.push_str(&format!("\n{}", link_type.full_print_on_one_line(language))); @@ -186,14 +186,14 @@ fn body_no_packets<'a>( .push(Space::with_height(FillPortion(2))) } -fn body_no_observed<'a>( - filters: &'a Filters, +fn body_no_observed( + filters: &Filters, observed: u128, font: Font, font_headers: Font, language: Language, waiting: &str, -) -> Column<'a, Message, StyleType> { +) -> Column<'static, Message, StyleType> { let tot_packets_text = some_observed_translation(language, observed) .align_x(Alignment::Center) .font(font); @@ -218,12 +218,12 @@ fn body_no_observed<'a>( .push(Space::with_height(FillPortion(2))) } -fn body_pcap_error<'a>( - pcap_error: &'a str, +fn body_pcap_error( + pcap_error: &str, waiting: &str, language: Language, font: Font, -) -> Column<'a, Message, StyleType> { +) -> Column<'static, Message, StyleType> { // let err_string = pcap_error.clone().unwrap(); let error_text = error_translation(language, pcap_error) .align_x(Alignment::Center) @@ -242,7 +242,7 @@ fn body_pcap_error<'a>( .push(Space::with_height(FillPortion(2))) } -fn lazy_row_report<'a>(sniffer: &Sniffer) -> Container<'a, Message, StyleType> { +fn lazy_row_report(sniffer: &Sniffer) -> Container<'static, Message, StyleType> { let col_host = col_host(840.0, sniffer); let col_service = col_service(250.0, sniffer); @@ -257,7 +257,7 @@ fn lazy_row_report<'a>(sniffer: &Sniffer) -> Container<'a, Message, StyleType> { .class(ContainerType::BorderedRound) } -fn col_host(width: f32, sniffer: &Sniffer) -> Column { +fn col_host(width: f32, sniffer: &Sniffer) -> Column<'static, Message, StyleType> { let ConfigSettings { style, language, .. } = sniffer.configs.lock().unwrap().settings; @@ -362,7 +362,7 @@ fn col_host(width: f32, sniffer: &Sniffer) -> Column { ) } -fn col_service(width: f32, sniffer: &Sniffer) -> Column { +fn col_service(width: f32, sniffer: &Sniffer) -> Column<'static, Message, StyleType> { let ConfigSettings { style, language, .. } = sniffer.configs.lock().unwrap().settings; @@ -442,12 +442,12 @@ fn col_service(width: f32, sniffer: &Sniffer) -> Column { ) } -fn lazy_col_info<'a>( +fn lazy_col_info( total: u128, filtered: u128, dropped: u32, sniffer: &Sniffer, -) -> Container<'a, Message, StyleType> { +) -> Container<'static, Message, StyleType> { let ConfigSettings { style, language, .. } = sniffer.configs.lock().unwrap().settings; @@ -539,7 +539,11 @@ fn container_chart(sniffer: &Sniffer, font: Font) -> Container Column { +fn col_device( + language: Language, + font: Font, + device: &MyDevice, +) -> Column<'static, Message, StyleType> { let link_type = device.link_type; #[cfg(not(target_os = "windows"))] let adapter_info = &device.name; @@ -557,11 +561,11 @@ fn col_device(language: Language, font: Font, device: &MyDevice) -> Column( +fn col_data_representation( language: Language, font: Font, chart_type: ChartType, -) -> Column<'a, Message, StyleType> { +) -> Column<'static, Message, StyleType> { let mut ret_val = Column::new().spacing(5).push( Text::new(format!("{}:", data_representation_translation(language))) .class(TextType::Subtitle) @@ -599,7 +603,7 @@ fn col_bytes_packets( font: Font, font_headers: Font, sniffer: &Sniffer, -) -> Column { +) -> Column<'static, Message, StyleType> { let filtered_bytes = sniffer.runtime_data.tot_out_bytes + sniffer.runtime_data.tot_in_bytes; let all_bytes = sniffer.runtime_data.all_bytes; let filters = &sniffer.filters; @@ -724,7 +728,7 @@ fn get_bars_length( (in_len, out_len) } -fn get_bars<'a>(in_len: f32, out_len: f32) -> Row<'a, Message, StyleType> { +fn get_bars(in_len: f32, out_len: f32) -> Row<'static, Message, StyleType> { Row::new() .push(if in_len > 0.0 { Row::new() @@ -742,7 +746,7 @@ fn get_bars<'a>(in_len: f32, out_len: f32) -> Row<'a, Message, StyleType> { }) } -fn get_star_button<'a>(is_favorite: bool, host: Host) -> Button<'a, Message, StyleType> { +fn get_star_button(is_favorite: bool, host: Host) -> Button<'static, Message, StyleType> { button( Icon::Star .to_text() @@ -767,7 +771,7 @@ fn get_active_filters_col( font: Font, font_headers: Font, show: bool, -) -> Column { +) -> Column<'static, Message, StyleType> { let mut ret_val = Column::new().push( Text::new(format!("{}:", active_filters_translation(language),)) .font(font) @@ -804,10 +808,10 @@ fn get_active_filters_col( ret_val } -fn sort_arrows<'a>( +fn sort_arrows( active_sort_type: SortType, message: fn(SortType) -> Message, -) -> Container<'a, Message, StyleType> { +) -> Container<'static, Message, StyleType> { Container::new( button( active_sort_type