From 1b29f86737e7efd3cb29d29c55bd5d25b703aca5 Mon Sep 17 00:00:00 2001 From: GyulyVGC Date: Sat, 21 Sep 2024 00:51:44 +0200 Subject: [PATCH] fixing lifetimes --- src/chart/types/traffic_chart.rs | 2 +- src/countries/country_utils.rs | 12 ++--- src/gui/components/button.rs | 10 ++-- src/gui/components/footer.rs | 20 ++++---- src/gui/components/header.rs | 16 +++---- src/gui/components/modal.rs | 14 +++--- src/gui/components/tab.rs | 20 ++++---- src/gui/pages/connection_details_page.rs | 41 ++++++++-------- src/gui/pages/initial_page.rs | 22 +++------ src/gui/pages/inspect_page.rs | 38 +++++++-------- src/gui/pages/notifications_page.rs | 25 +++++----- src/gui/pages/overview_page.rs | 50 +++++++++----------- src/gui/pages/settings_general_page.rs | 31 ++++++------ src/gui/pages/settings_notifications_page.rs | 34 ++++++------- src/gui/pages/settings_style_page.rs | 18 +++---- src/gui/pages/thumbnail_page.rs | 10 ++-- src/gui/pages/types/running_page.rs | 2 +- src/gui/pages/types/settings_page.rs | 2 +- src/gui/sniffer.rs | 2 +- src/gui/styles/text.rs | 4 +- src/networking/types/my_link_type.rs | 4 +- src/notifications/types/sound.rs | 2 +- src/report/types/report_col.rs | 2 +- src/report/types/report_sort_type.rs | 2 +- src/report/types/sort_type.rs | 2 +- src/translations/translations.rs | 32 ++++++------- src/translations/translations_3.rs | 4 +- src/translations/types/language.rs | 2 +- src/utils/types/icon.rs | 4 +- 29 files changed, 203 insertions(+), 224 deletions(-) diff --git a/src/chart/types/traffic_chart.rs b/src/chart/types/traffic_chart.rs index c78f2215..df8afe5f 100644 --- a/src/chart/types/traffic_chart.rs +++ b/src/chart/types/traffic_chart.rs @@ -118,7 +118,7 @@ impl TrafficChart { min - gap..max + gap } - fn font(&self, size: f64) -> TextStyle<'static> { + fn font<'a>(&self, size: f64) -> TextStyle<'a> { (FONT_FAMILY_NAME, size) .into_font() .style(self.style.get_font_weight()) diff --git a/src/countries/country_utils.rs b/src/countries/country_utils.rs index 82d5dd7e..39ac6ee8 100644 --- a/src/countries/country_utils.rs +++ b/src/countries/country_utils.rs @@ -28,14 +28,14 @@ use crate::translations::translations_2::{ }; use crate::{Language, StyleType}; -fn get_flag_from_country( +fn get_flag_from_country<'a>( country: Country, width: f32, is_local: bool, is_loopback: bool, traffic_type: TrafficType, language: Language, -) -> (Svg<'static, StyleType>, String) { +) -> (Svg<'a, StyleType>, String) { #![allow(clippy::too_many_lines)] let mut tooltip = country.to_string(); let mut svg_style = SvgType::Standard; @@ -310,13 +310,13 @@ fn get_flag_from_country( (svg, tooltip) } -pub fn get_flag_tooltip( +pub fn get_flag_tooltip<'a>( country: Country, host_info: &DataInfoHost, language: Language, font: Font, thumbnail: bool, -) -> Tooltip<'static, Message, StyleType> { +) -> Tooltip<'a, Message, StyleType> { let width = if thumbnail { FLAGS_WIDTH_SMALL } else { @@ -355,13 +355,13 @@ pub fn get_flag_tooltip( tooltip } -pub fn get_computer_tooltip( +pub fn get_computer_tooltip<'a>( is_my_address: bool, is_local: bool, traffic_type: TrafficType, language: Language, font: Font, -) -> Tooltip<'static, Message, StyleType> { +) -> Tooltip<'a, Message, StyleType> { let content = Svg::new(Handle::from_memory(Vec::from( match (is_my_address, is_local, traffic_type) { (true, _, _) => COMPUTER, diff --git a/src/gui/components/button.rs b/src/gui/components/button.rs index f1618872..4d9de889 100644 --- a/src/gui/components/button.rs +++ b/src/gui/components/button.rs @@ -13,11 +13,11 @@ use crate::utils::types::file_info::FileInfo; use crate::utils::types::icon::Icon; use crate::{Language, StyleType}; -pub fn button_hide( +pub fn button_hide<'a>( message: Message, language: Language, font: Font, -) -> Tooltip<'static, Message, StyleType> { +) -> Tooltip<'a, Message, StyleType> { Tooltip::new( button( Text::new("×") @@ -38,14 +38,14 @@ pub fn button_hide( .class(ContainerType::Tooltip) } -pub fn button_open_file( +pub fn button_open_file<'a>( old_file: String, file_info: FileInfo, language: Language, font: Font, is_editable: bool, action: fn(String) -> Message, -) -> Tooltip<'static, Message, StyleType> { +) -> Tooltip<'a, Message, StyleType> { let mut tooltip_str = ""; let mut tooltip_style = ContainerType::Standard; @@ -71,7 +71,7 @@ pub fn button_open_file( .class(tooltip_style) } -pub fn row_open_link_tooltip(text: &'static str, font: Font) -> Row<'static, Message, StyleType> { +pub fn row_open_link_tooltip(text: &'static str, font: Font) -> Row { Row::new() .align_y(Alignment::Center) .spacing(10) diff --git a/src/gui/components/footer.rs b/src/gui/components/footer.rs index 8d443eae..972bca7a 100644 --- a/src/gui/components/footer.rs +++ b/src/gui/components/footer.rs @@ -22,14 +22,14 @@ use crate::utils::types::icon::Icon; use crate::utils::types::web_page::WebPage; use crate::{Language, SNIFFNET_TITLECASE}; -pub fn footer( +pub fn footer<'a>( thumbnail: bool, language: Language, color_gradient: GradientType, font: Font, font_footer: Font, - newer_release_available: &Arc>>, -) -> Container<'static, Message, StyleType> { + newer_release_available: Arc>>, +) -> Container<'a, Message, StyleType> { if thumbnail { return thumbnail_footer(); } @@ -59,7 +59,7 @@ pub fn footer( .class(ContainerType::Gradient(color_gradient)) } -fn get_button_website(font: Font) -> Tooltip<'static, Message, StyleType> { +fn get_button_website<'a>(font: Font) -> Tooltip<'a, Message, StyleType> { let content = button( Icon::Globe .to_text() @@ -80,7 +80,7 @@ fn get_button_website(font: Font) -> Tooltip<'static, Message, StyleType> { .class(ContainerType::Tooltip) } -fn get_button_github(font: Font) -> Tooltip<'static, Message, StyleType> { +fn get_button_github<'a>(font: Font) -> Tooltip<'a, Message, StyleType> { let content = button( Icon::GitHub .to_text() @@ -101,7 +101,7 @@ fn get_button_github(font: Font) -> Tooltip<'static, Message, StyleType> { .class(ContainerType::Tooltip) } -fn get_button_sponsor(font: Font) -> Tooltip<'static, Message, StyleType> { +fn get_button_sponsor<'a>(font: Font) -> Tooltip<'a, Message, StyleType> { let content = button( Text::new('❤'.to_string()) .font(font) @@ -124,12 +124,12 @@ fn get_button_sponsor(font: Font) -> Tooltip<'static, Message, StyleType> { .class(ContainerType::Tooltip) } -fn get_release_details( +fn get_release_details<'a>( language: Language, font: Font, font_footer: Font, - newer_release_available: &Arc>>, -) -> Row<'static, Message, StyleType> { + newer_release_available: Arc>>, +) -> Row<'a, Message, StyleType> { let mut ret_val = Row::new() .align_y(Alignment::Center) .height(Length::Fill) @@ -170,6 +170,6 @@ fn get_release_details( ret_val } -fn thumbnail_footer() -> Container<'static, Message, StyleType> { +fn thumbnail_footer<'a>() -> Container<'a, Message, StyleType> { Container::new(horizontal_space()).height(0) } diff --git a/src/gui/components/header.rs b/src/gui/components/header.rs index d255aa3b..9a71531f 100644 --- a/src/gui/components/header.rs +++ b/src/gui/components/header.rs @@ -19,7 +19,7 @@ use crate::translations::translations_3::thumbnail_mode_translation; use crate::utils::types::icon::Icon; use crate::{Language, StyleType, SNIFFNET_TITLECASE}; -pub fn header(sniffer: &Sniffer) -> Container<'static, Message, StyleType> { +pub fn header<'a>(sniffer: &Sniffer) -> Container<'a, Message, StyleType> { let thumbnail = sniffer.thumbnail; let ConfigSettings { style, @@ -78,7 +78,7 @@ pub fn header(sniffer: &Sniffer) -> Container<'static, Message, StyleType> { .class(ContainerType::Gradient(color_gradient)) } -fn get_button_reset(font: Font, language: Language) -> Tooltip<'static, Message, StyleType> { +fn get_button_reset<'a>(font: Font, language: Language) -> Tooltip<'a, Message, StyleType> { let content = button( Icon::ArrowBack .to_text() @@ -101,11 +101,11 @@ fn get_button_reset(font: Font, language: Language) -> Tooltip<'static, Message, .class(ContainerType::Tooltip) } -pub fn get_button_settings( +pub fn get_button_settings<'a>( font: Font, language: Language, open_overlay: SettingsPage, -) -> Tooltip<'static, Message, StyleType> { +) -> Tooltip<'a, Message, StyleType> { let content = button( Icon::Settings .to_text() @@ -127,11 +127,11 @@ pub fn get_button_settings( .class(ContainerType::Tooltip) } -pub fn get_button_minimize( +pub fn get_button_minimize<'a>( font: Font, language: Language, thumbnail: bool, -) -> Tooltip<'static, Message, StyleType> { +) -> Tooltip<'a, Message, StyleType> { let size = if thumbnail { 20 } else { 24 }; let button_size = if thumbnail { 30 } else { 40 }; let icon = if thumbnail { @@ -167,13 +167,13 @@ pub fn get_button_minimize( .class(tooltip_style) } -fn thumbnail_header( +fn thumbnail_header<'a>( font: Font, font_headers: Font, language: Language, color_gradient: GradientType, unread_notifications: usize, -) -> Container<'static, Message, StyleType> { +) -> Container<'a, Message, StyleType> { Container::new( Row::new() .align_y(Alignment::Center) diff --git a/src/gui/components/modal.rs b/src/gui/components/modal.rs index b4866a5e..533edbe0 100644 --- a/src/gui/components/modal.rs +++ b/src/gui/components/modal.rs @@ -17,12 +17,12 @@ use crate::translations::translations::{ }; use crate::{Language, StyleType}; -pub fn get_exit_overlay( +pub fn get_exit_overlay<'a>( color_gradient: GradientType, font: Font, font_headers: Font, language: Language, -) -> Container<'static, Message, StyleType> { +) -> Container<'a, Message, StyleType> { let row_buttons = confirm_button_row(language, font, Message::Reset); let content = Column::new() @@ -49,12 +49,12 @@ pub fn get_exit_overlay( .class(ContainerType::Modal) } -pub fn get_clear_all_overlay( +pub fn get_clear_all_overlay<'a>( color_gradient: GradientType, font: Font, font_headers: Font, language: Language, -) -> Container<'static, Message, StyleType> { +) -> Container<'a, Message, StyleType> { let row_buttons = confirm_button_row(language, font, Message::ClearAllNotifications); let content = Column::new() @@ -87,7 +87,7 @@ fn get_modal_header( color_gradient: GradientType, language: Language, title: &'static str, -) -> Container<'static, Message, StyleType> { +) -> Container { Container::new( Row::new() .push(horizontal_space()) @@ -111,11 +111,11 @@ fn get_modal_header( .class(ContainerType::Gradient(color_gradient)) } -fn confirm_button_row( +fn confirm_button_row<'a>( language: Language, font: Font, message: Message, -) -> Row<'static, Message, StyleType> { +) -> Row<'a, Message, StyleType> { Row::new() .height(Length::Fill) .align_y(Alignment::Center) diff --git a/src/gui/components/tab.rs b/src/gui/components/tab.rs index c725cad5..0592a376 100644 --- a/src/gui/components/tab.rs +++ b/src/gui/components/tab.rs @@ -12,11 +12,11 @@ use crate::gui::styles::text::TextType; use crate::gui::types::message::Message; use crate::{Language, RunningPage, StyleType}; -pub fn get_settings_tabs( +pub fn get_settings_tabs<'a>( active: SettingsPage, font: Font, language: Language, -) -> Row<'static, Message, StyleType> { +) -> Row<'a, Message, StyleType> { let mut tabs = Row::new() .width(Length::Fill) .align_y(Alignment::Start) @@ -30,13 +30,13 @@ pub fn get_settings_tabs( tabs } -pub fn get_pages_tabs( +pub fn get_pages_tabs<'a>( active: RunningPage, font: Font, font_headers: Font, language: Language, unread_notifications: usize, -) -> Row<'static, Message, StyleType> { +) -> Row<'a, Message, StyleType> { let mut tabs = Row::new() .width(Length::Fill) .align_y(Alignment::Start) @@ -62,14 +62,14 @@ pub fn get_pages_tabs( tabs } -fn new_page_tab( +fn new_page_tab<'a>( page: RunningPage, active: bool, language: Language, font: Font, font_headers: Font, unread: Option, -) -> Button<'static, Message, StyleType> { +) -> Button<'a, Message, StyleType> { let mut content = Row::new() .height(Length::Fill) .align_y(Alignment::Center) @@ -121,12 +121,12 @@ fn new_page_tab( .on_press(page.action()) } -fn new_settings_tab( +fn new_settings_tab<'a>( page: SettingsPage, active: bool, language: Language, font: Font, -) -> Button<'static, Message, StyleType> { +) -> Button<'a, Message, StyleType> { let content = Row::new() .height(Length::Fill) .align_y(Alignment::Center) @@ -169,10 +169,10 @@ fn new_settings_tab( .on_press(page.action()) } -pub fn notifications_badge( +pub fn notifications_badge<'a>( font_headers: Font, num: usize, -) -> Container<'static, Message, StyleType> { +) -> Container<'a, Message, StyleType> { Container::new( Text::new(num.to_string()) .font(font_headers) diff --git a/src/gui/pages/connection_details_page.rs b/src/gui/pages/connection_details_page.rs index 110f9ba8..e2424ffe 100644 --- a/src/gui/pages/connection_details_page.rs +++ b/src/gui/pages/connection_details_page.rs @@ -53,10 +53,7 @@ pub fn connection_details_page( )) } -fn page_content( - sniffer: &Sniffer, - key: &AddressPortPair, -) -> Container<'static, Message, StyleType> { +fn page_content<'a>(sniffer: &Sniffer, key: &AddressPortPair) -> Container<'a, Message, StyleType> { let ConfigSettings { style, language, @@ -151,12 +148,12 @@ fn page_content( .class(ContainerType::Modal) } -fn page_header( +fn page_header<'a>( font: Font, font_headers: Font, color_gradient: GradientType, language: Language, -) -> Container<'static, Message, StyleType> { +) -> Container<'a, Message, StyleType> { Container::new( Row::new() .push(horizontal_space()) @@ -180,12 +177,12 @@ fn page_header( .class(ContainerType::Gradient(color_gradient)) } -fn col_info( +fn col_info<'a>( key: &AddressPortPair, val: &InfoAddressPortPair, font: Font, language: Language, -) -> Column<'static, Message, StyleType> { +) -> Column<'a, Message, StyleType> { let is_icmp = key.protocol.eq(&Protocol::ICMP); let mut ret_val = Column::new() @@ -262,12 +259,12 @@ fn col_info( ret_val } -fn get_host_info_col( +fn get_host_info_col<'a>( r_dns: &str, host: &Host, font: Font, language: Language, -) -> Column<'static, Message, StyleType> { +) -> Column<'a, Message, StyleType> { let mut host_info_col = Column::new().spacing(4); if r_dns.parse::().is_err() || (!host.asn.name.is_empty() && !host.asn.code.is_empty()) { @@ -290,11 +287,11 @@ fn get_host_info_col( host_info_col } -fn get_local_tooltip( +fn get_local_tooltip<'a>( sniffer: &Sniffer, address_to_lookup: &str, key: &AddressPortPair, -) -> Tooltip<'static, Message, StyleType> { +) -> Tooltip<'a, Message, StyleType> { let ConfigSettings { style, language, .. } = sniffer.configs.lock().unwrap().settings; @@ -322,15 +319,15 @@ fn get_local_tooltip( ) } -fn get_src_or_dest_col( - caption: Row<'static, Message, StyleType>, +fn get_src_or_dest_col<'a>( + caption: Row<'a, Message, StyleType>, ip: &String, port: Option, mac: &Option, font: Font, language: Language, timing_events: &TimingEvents, -) -> Column<'static, Message, StyleType> { +) -> Column<'a, Message, StyleType> { let address_caption = if port.is_some() { socket_address_translation(language) } else { @@ -365,11 +362,11 @@ fn get_src_or_dest_col( )) } -fn assemble_widgets( - col_info: Column<'static, Message, StyleType>, - source_col: Column<'static, Message, StyleType>, - dest_col: Column<'static, Message, StyleType>, -) -> Row<'static, Message, StyleType> { +fn assemble_widgets<'a>( + col_info: Column<'a, Message, StyleType>, + source_col: Column<'a, Message, StyleType>, + dest_col: Column<'a, Message, StyleType>, +) -> Row<'a, Message, StyleType> { let [source_container, dest_container] = [source_col, dest_col].map(|col| { Container::new(col) .padding(7) @@ -396,12 +393,12 @@ fn assemble_widgets( ) } -fn get_button_copy( +fn get_button_copy<'a>( language: Language, font: Font, string: &String, timing_events: &TimingEvents, -) -> Tooltip<'static, Message, StyleType> { +) -> Tooltip<'a, Message, StyleType> { let icon = if timing_events.was_just_copy_ip(string) { Text::new("✔").font(font).size(14) } else { diff --git a/src/gui/pages/initial_page.rs b/src/gui/pages/initial_page.rs index 8ea45aa1..d1cfd9d1 100644 --- a/src/gui/pages/initial_page.rs +++ b/src/gui/pages/initial_page.rs @@ -41,7 +41,7 @@ use crate::utils::types::icon::Icon; use crate::{ConfigSettings, IpVersion, Language, Protocol, StyleType}; /// Computes the body of gui initial page -pub fn initial_page(sniffer: &Sniffer) -> Container { +pub fn initial_page<'a>(sniffer: &'a Sniffer) -> Container<'a, Message, StyleType> { let ConfigSettings { style, language, @@ -119,7 +119,7 @@ fn col_ip_buttons( active_ip_filters: &HashSet, font: Font, language: Language, -) -> Column<'static, Message, StyleType> { +) -> Column { let mut buttons_row = Row::new().spacing(5).padding([0, 0, 0, 5]); for option in IpVersion::ALL { let is_active = active_ip_filters.contains(&option); @@ -158,7 +158,7 @@ fn col_protocol_buttons( active_protocol_filters: &HashSet, font: Font, language: Language, -) -> Column<'static, Message, StyleType> { +) -> Column { let mut buttons_row = Row::new().spacing(5).padding([0, 0, 0, 5]); for option in Protocol::ALL { let is_active = active_protocol_filters.contains(&option); @@ -193,11 +193,7 @@ fn col_protocol_buttons( .push(buttons_row) } -fn col_address_input( - value: &str, - font: Font, - language: Language, -) -> Column<'static, Message, StyleType> { +fn col_address_input(value: &str, font: Font, language: Language) -> Column { let is_error = if value.is_empty() { false } else { @@ -228,11 +224,7 @@ fn col_address_input( .push(input_row) } -fn col_port_input( - value: &str, - font: Font, - language: Language, -) -> Column<'static, Message, StyleType> { +fn col_port_input(value: &str, font: Font, language: Language) -> Column { let is_error = if value.is_empty() { false } else { @@ -268,7 +260,7 @@ fn button_start( language: Language, color_gradient: GradientType, filters: &Filters, -) -> Tooltip<'static, Message, StyleType> { +) -> Tooltip { let mut content = button( Icon::Rocket .to_text() @@ -370,7 +362,7 @@ fn get_export_pcap_group( export_pcap: &ExportPcap, language: Language, font: Font, -) -> Container<'static, Message, StyleType> { +) -> Container { let enabled = export_pcap.enabled(); let file_name = export_pcap.file_name(); let directory = export_pcap.directory(); diff --git a/src/gui/pages/inspect_page.rs b/src/gui/pages/inspect_page.rs index 869a6061..b4871ab4 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(sniffer: &Sniffer) -> Container { +pub fn inspect_page<'a>(sniffer: &Sniffer) -> Container<'a, Message, StyleType> { let ConfigSettings { style, language, .. } = sniffer.configs.lock().unwrap().settings; @@ -103,7 +103,7 @@ pub fn inspect_page(sniffer: &Sniffer) -> Container { Container::new(Column::new().push(tab_and_body.push(body))).height(Length::Fill) } -fn lazy_report(sniffer: &Sniffer) -> Column<'static, Message, StyleType> { +fn lazy_report(sniffer: &Sniffer) -> Column { let ConfigSettings { style, language, .. } = sniffer.configs.lock().unwrap().settings; @@ -169,7 +169,7 @@ fn report_header_row( search_params: &SearchParameters, font: Font, sort_type: ReportSortType, -) -> Row<'static, Message, StyleType> { +) -> Row { let mut ret_val = Row::new().padding([0, 2]).align_y(Alignment::Center); for report_col in ReportCol::ALL { let (title_display, title_small_display, tooltip_val) = @@ -210,7 +210,7 @@ fn report_header_row( .align_y(Alignment::Center), ); } else { - col_header = col_header.push(sort_arrows(sort_type, &report_col)); + col_header = col_header.push(sort_arrows(sort_type, report_col)); } ret_val = ret_val.push(col_header); } @@ -252,10 +252,10 @@ fn title_report_col_display( } } -fn sort_arrows( +fn sort_arrows<'a>( active_sort_type: ReportSortType, - report_col: &ReportCol, -) -> Container<'static, Message, StyleType> { + report_col: ReportCol, +) -> Container<'a, Message, StyleType> { Container::new( button( active_sort_type @@ -263,20 +263,20 @@ fn sort_arrows( .align_x(Alignment::Center) .align_y(Alignment::Center), ) - .class(active_sort_type.button_type(report_col)) + .class(active_sort_type.button_type(&report_col)) .on_press(Message::ReportSortSelection( - active_sort_type.next_sort(report_col), + active_sort_type.next_sort(&report_col), )), ) .align_y(Alignment::Center) .height(Length::Fill) } -fn row_report_entry( +fn row_report_entry<'a>( key: &AddressPortPair, val: &InfoAddressPortPair, font: Font, -) -> Row<'static, Message, StyleType> { +) -> Row<'a, Message, StyleType> { let text_type = if val.traffic_direction == TrafficDirection::Outgoing { TextType::Outgoing } else { @@ -309,7 +309,7 @@ fn host_filters_col( search_params: &SearchParameters, font: Font, language: Language, -) -> Column<'static, Message, StyleType> { +) -> Column { let search_params2 = search_params.clone(); let mut title_row = Row::new().spacing(10).align_y(Alignment::Center).push( @@ -391,11 +391,11 @@ fn host_filters_col( ) } -fn filter_input( +fn filter_input<'a>( filter_input_type: FilterInputType, search_params: SearchParameters, font: Font, -) -> Container<'static, Message, StyleType> { +) -> Container<'a, Message, StyleType> { let filter_value = filter_input_type.current_value(&search_params); let is_filter_active = !filter_value.is_empty(); @@ -444,7 +444,7 @@ fn filter_input( }) } -fn get_button_change_page(increment: bool) -> Button<'static, Message, StyleType> { +fn get_button_change_page<'a>(increment: bool) -> Button<'a, Message, StyleType> { button( if increment { Icon::ArrowRight @@ -462,14 +462,14 @@ fn get_button_change_page(increment: bool) -> Button<'static, Message, StyleType .on_press(Message::UpdatePageNumber(increment)) } -fn get_change_page_row( +fn get_change_page_row<'a>( font: Font, language: Language, page_number: usize, start_entry_num: usize, end_entry_num: usize, results_number: usize, -) -> Row<'static, Message, StyleType> { +) -> Row<'a, Message, StyleType> { Row::new() .height(40) .align_y(Alignment::Center) @@ -497,10 +497,10 @@ fn get_change_page_row( .push(horizontal_space()) } -fn button_clear_filter( +fn button_clear_filter<'a>( new_search_parameters: SearchParameters, font: Font, -) -> Button<'static, Message, StyleType> { +) -> Button<'a, Message, StyleType> { button( Text::new("×") .font(font) diff --git a/src/gui/pages/notifications_page.rs b/src/gui/pages/notifications_page.rs index a1410320..e279ac69 100644 --- a/src/gui/pages/notifications_page.rs +++ b/src/gui/pages/notifications_page.rs @@ -30,7 +30,7 @@ use crate::utils::types::icon::Icon; use crate::{ByteMultiple, ConfigSettings, Language, RunningPage, Sniffer, StyleType}; /// Computes the body of gui notifications page -pub fn notifications_page(sniffer: &Sniffer) -> Container { +pub fn notifications_page<'a>(sniffer: &'a Sniffer) -> Container<'a, Message, StyleType> { let ConfigSettings { style, language, @@ -105,10 +105,7 @@ pub fn notifications_page(sniffer: &Sniffer) -> Container { Container::new(Column::new().push(tab_and_body)).height(Length::Fill) } -fn body_no_notifications_set( - font: Font, - language: Language, -) -> Column<'static, Message, StyleType> { +fn body_no_notifications_set<'a>(font: Font, language: Language) -> Column<'a, Message, StyleType> { Column::new() .padding(5) .spacing(5) @@ -132,7 +129,7 @@ fn body_no_notifications_received( font: Font, language: Language, waiting: &str, -) -> Column<'static, Message, StyleType> { +) -> Column { Column::new() .padding(5) .spacing(5) @@ -148,11 +145,11 @@ fn body_no_notifications_received( .push(Space::with_height(FillPortion(2))) } -fn packets_notification_log( +fn packets_notification_log<'a>( logged_notification: PacketsThresholdExceeded, language: Language, font: Font, -) -> Container<'static, Message, StyleType> { +) -> Container<'a, Message, StyleType> { let threshold_str = format!( "{}: {} {}", threshold_translation(language), @@ -224,11 +221,11 @@ fn packets_notification_log( .class(ContainerType::BorderedRound) } -fn bytes_notification_log( +fn bytes_notification_log<'a>( logged_notification: BytesThresholdExceeded, language: Language, font: Font, -) -> Container<'static, Message, StyleType> { +) -> Container<'a, Message, StyleType> { let mut threshold_str = threshold_translation(language).to_string(); threshold_str.push_str(": "); threshold_str.push_str(&ByteMultiple::formatted_string( @@ -307,11 +304,11 @@ fn bytes_notification_log( .class(ContainerType::BorderedRound) } -fn favorite_notification_log( +fn favorite_notification_log<'a>( logged_notification: FavoriteTransmitted, language: Language, font: Font, -) -> Container<'static, Message, StyleType> { +) -> Container<'a, Message, StyleType> { let country = logged_notification.host.country; let asn = &logged_notification.host.asn; @@ -377,7 +374,7 @@ fn favorite_notification_log( .class(ContainerType::BorderedRound) } -fn get_button_clear_all(font: Font, language: Language) -> Tooltip<'static, Message, StyleType> { +fn get_button_clear_all<'a>(font: Font, language: Language) -> Tooltip<'a, Message, StyleType> { let content = button( Icon::Bin .to_text() @@ -399,7 +396,7 @@ fn get_button_clear_all(font: Font, language: Language) -> Tooltip<'static, Mess .class(ContainerType::Tooltip) } -fn lazy_logged_notifications(sniffer: &Sniffer) -> Column<'static, Message, StyleType> { +fn lazy_logged_notifications<'a>(sniffer: &Sniffer) -> Column<'a, 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 414ff4f5..69ec36c8 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(sniffer: &Sniffer) -> Container { +pub fn overview_page<'a>(sniffer: &'a Sniffer) -> Container<'a, Message, StyleType> { let ConfigSettings { style, language, .. } = sniffer.configs.lock().unwrap().settings; @@ -141,12 +141,12 @@ pub fn overview_page(sniffer: &Sniffer) -> Container { Container::new(Column::new().push(tab_and_body.push(body))).height(Length::Fill) } -fn body_no_packets( +fn body_no_packets<'a>( device: &MyDevice, font: Font, language: Language, waiting: &str, -) -> Column<'static, Message, StyleType> { +) -> Column<'a, 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( .push(Space::with_height(FillPortion(2))) } -fn body_no_observed( - filters: &Filters, +fn body_no_observed<'a>( + filters: &'a Filters, observed: u128, font: Font, font_headers: Font, language: Language, waiting: &str, -) -> Column<'static, Message, StyleType> { +) -> Column<'a, 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( .push(Space::with_height(FillPortion(2))) } -fn body_pcap_error( - pcap_error: &str, +fn body_pcap_error<'a>( + pcap_error: &'a str, waiting: &str, language: Language, font: Font, -) -> Column<'static, Message, StyleType> { +) -> Column<'a, 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( .push(Space::with_height(FillPortion(2))) } -fn lazy_row_report(sniffer: &Sniffer) -> Container<'static, Message, StyleType> { +fn lazy_row_report<'a>(sniffer: &Sniffer) -> Container<'a, 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(sniffer: &Sniffer) -> Container<'static, Message, StyleType> .class(ContainerType::BorderedRound) } -fn col_host(width: f32, sniffer: &Sniffer) -> Column<'static, Message, StyleType> { +fn col_host(width: f32, sniffer: &Sniffer) -> Column { let ConfigSettings { style, language, .. } = sniffer.configs.lock().unwrap().settings; @@ -362,7 +362,7 @@ fn col_host(width: f32, sniffer: &Sniffer) -> Column<'static, Message, StyleType ) } -fn col_service(width: f32, sniffer: &Sniffer) -> Column<'static, Message, StyleType> { +fn col_service(width: f32, sniffer: &Sniffer) -> Column { let ConfigSettings { style, language, .. } = sniffer.configs.lock().unwrap().settings; @@ -442,12 +442,12 @@ fn col_service(width: f32, sniffer: &Sniffer) -> Column<'static, Message, StyleT ) } -fn lazy_col_info( +fn lazy_col_info<'a>( total: u128, filtered: u128, dropped: u32, sniffer: &Sniffer, -) -> Container<'static, Message, StyleType> { +) -> Container<'a, Message, StyleType> { let ConfigSettings { style, language, .. } = sniffer.configs.lock().unwrap().settings; @@ -539,11 +539,7 @@ fn container_chart(sniffer: &Sniffer, font: Font) -> Container Column<'static, Message, StyleType> { +fn col_device(language: Language, font: Font, device: &MyDevice) -> Column { let link_type = device.link_type; #[cfg(not(target_os = "windows"))] let adapter_info = &device.name; @@ -561,11 +557,11 @@ fn col_device( .push(link_type.link_type_col(language, font)) } -fn col_data_representation( +fn col_data_representation<'a>( language: Language, font: Font, chart_type: ChartType, -) -> Column<'static, Message, StyleType> { +) -> Column<'a, Message, StyleType> { let mut ret_val = Column::new().spacing(5).push( Text::new(format!("{}:", data_representation_translation(language))) .class(TextType::Subtitle) @@ -603,7 +599,7 @@ fn col_bytes_packets( font: Font, font_headers: Font, sniffer: &Sniffer, -) -> Column<'static, Message, StyleType> { +) -> Column { 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; @@ -728,7 +724,7 @@ fn get_bars_length( (in_len, out_len) } -fn get_bars(in_len: f32, out_len: f32) -> Row<'static, Message, StyleType> { +fn get_bars<'a>(in_len: f32, out_len: f32) -> Row<'a, Message, StyleType> { Row::new() .push(if in_len > 0.0 { Row::new() @@ -746,7 +742,7 @@ fn get_bars(in_len: f32, out_len: f32) -> Row<'static, Message, StyleType> { }) } -fn get_star_button(is_favorite: bool, host: Host) -> Button<'static, Message, StyleType> { +fn get_star_button<'a>(is_favorite: bool, host: Host) -> Button<'a, Message, StyleType> { button( Icon::Star .to_text() @@ -771,7 +767,7 @@ fn get_active_filters_col( font: Font, font_headers: Font, show: bool, -) -> Column<'static, Message, StyleType> { +) -> Column { let mut ret_val = Column::new().push( Text::new(format!("{}:", active_filters_translation(language),)) .font(font) @@ -808,10 +804,10 @@ fn get_active_filters_col( ret_val } -fn sort_arrows( +fn sort_arrows<'a>( active_sort_type: SortType, message: fn(SortType) -> Message, -) -> Container<'static, Message, StyleType> { +) -> Container<'a, Message, StyleType> { Container::new( button( active_sort_type diff --git a/src/gui/pages/settings_general_page.rs b/src/gui/pages/settings_general_page.rs index 03840218..4ae59a09 100644 --- a/src/gui/pages/settings_general_page.rs +++ b/src/gui/pages/settings_general_page.rs @@ -29,7 +29,7 @@ use crate::utils::types::icon::Icon; use crate::utils::types::web_page::WebPage; use crate::{ConfigSettings, Language, RunningPage, Sniffer, StyleType}; -pub fn settings_general_page(sniffer: &Sniffer) -> Container { +pub fn settings_general_page<'a>(sniffer: &'a Sniffer) -> Container<'a, Message, StyleType> { let ConfigSettings { style, language, @@ -58,10 +58,7 @@ pub fn settings_general_page(sniffer: &Sniffer) -> Container .class(ContainerType::Modal) } -fn column_all_general_setting( - sniffer: &Sniffer, - font: Font, -) -> Column<'static, Message, StyleType> { +fn column_all_general_setting(sniffer: &Sniffer, font: Font) -> Column { let ConfigSettings { language, scale_factor, @@ -101,11 +98,11 @@ fn column_all_general_setting( column } -fn row_language_scale_factor( +fn row_language_scale_factor<'a>( language: Language, font: Font, scale_factor: f64, -) -> Row<'static, Message, StyleType> { +) -> Row<'a, Message, StyleType> { Row::new() .align_y(Alignment::Start) .height(100) @@ -116,7 +113,7 @@ fn row_language_scale_factor( .push(need_help(language, font)) } -fn language_picklist(language: Language, font: Font) -> Container<'static, Message, StyleType> { +fn language_picklist<'a>(language: Language, font: Font) -> Container<'a, Message, StyleType> { let mut flag_row = Row::new() .align_y(Alignment::Center) .spacing(10) @@ -176,11 +173,11 @@ fn language_picklist(language: Language, font: Font) -> Container<'static, Messa .align_y(Alignment::Center) } -fn scale_factor_slider( +fn scale_factor_slider<'a>( language: Language, font: Font, scale_factor: f64, -) -> Container<'static, Message, StyleType> { +) -> Container<'a, Message, StyleType> { #[allow(clippy::cast_possible_truncation)] let slider_width = 130.0 / scale_factor as f32; let slider_val = scale_factor.log(3.0); @@ -208,7 +205,7 @@ fn scale_factor_slider( .align_y(Alignment::Center) } -fn need_help(language: Language, font: Font) -> Container<'static, Message, StyleType> { +fn need_help<'a>(language: Language, font: Font) -> Container<'a, Message, StyleType> { let content = Column::new() .align_x(Alignment::Center) .push( @@ -246,7 +243,7 @@ fn need_help(language: Language, font: Font) -> Container<'static, Message, Styl .align_y(Alignment::Center) } -fn mmdb_settings( +fn mmdb_settings<'a>( is_editable: bool, language: Language, font: Font, @@ -254,7 +251,7 @@ fn mmdb_settings( asn_path: &str, country_reader: &Arc, asn_reader: &Arc, -) -> Column<'static, Message, StyleType> { +) -> Column<'a, Message, StyleType> { Column::new() .spacing(5) .align_x(Alignment::Center) @@ -284,7 +281,7 @@ fn mmdb_settings( )) } -fn mmdb_selection_row( +fn mmdb_selection_row<'a>( is_editable: bool, font: Font, message: fn(String) -> Message, @@ -292,7 +289,7 @@ fn mmdb_selection_row( mmdb_reader: &Arc, caption: &str, language: Language, -) -> Row<'static, Message, StyleType> { +) -> Row<'a, Message, StyleType> { let is_error = if custom_path.is_empty() { false } else { @@ -328,11 +325,11 @@ fn mmdb_selection_row( }) } -fn button_clear_mmdb( +fn button_clear_mmdb<'a>( message: fn(String) -> Message, font: Font, is_editable: bool, -) -> Tooltip<'static, Message, StyleType> { +) -> Tooltip<'a, Message, StyleType> { let mut button = button( Text::new("×") .font(font) diff --git a/src/gui/pages/settings_notifications_page.rs b/src/gui/pages/settings_notifications_page.rs index 6565972f..ab8a0780 100644 --- a/src/gui/pages/settings_notifications_page.rs +++ b/src/gui/pages/settings_notifications_page.rs @@ -26,7 +26,7 @@ use crate::translations::translations::{ use crate::utils::types::icon::Icon; use crate::{ConfigSettings, Language, Sniffer, StyleType}; -pub fn settings_notifications_page(sniffer: &Sniffer) -> Container { +pub fn settings_notifications_page<'a>(sniffer: &Sniffer) -> Container<'a, Message, StyleType> { let ConfigSettings { style, language, @@ -97,11 +97,11 @@ pub fn settings_notifications_page(sniffer: &Sniffer) -> Container( packets_notification: PacketsNotification, language: Language, font: Font, -) -> Column<'static, Message, StyleType> { +) -> Column<'a, Message, StyleType> { let checkbox = Checkbox::new( packets_threshold_translation(language), packets_notification.threshold.is_some(), @@ -150,11 +150,11 @@ fn get_packets_notify( } } -fn get_bytes_notify( +fn get_bytes_notify<'a>( bytes_notification: BytesNotification, language: Language, font: Font, -) -> Column<'static, Message, StyleType> { +) -> Column<'a, Message, StyleType> { let checkbox = Checkbox::new( bytes_threshold_translation(language), bytes_notification.threshold.is_some(), @@ -203,11 +203,11 @@ fn get_bytes_notify( } } -fn get_favorite_notify( +fn get_favorite_notify<'a>( favorite_notification: FavoriteNotification, language: Language, font: Font, -) -> Column<'static, Message, StyleType> { +) -> Column<'a, Message, StyleType> { let checkbox = Checkbox::new( favorite_notification_translation(language), favorite_notification.notify_on_favorite, @@ -250,11 +250,11 @@ fn get_favorite_notify( } } -fn input_group_packets( +fn input_group_packets<'a>( packets_notification: PacketsNotification, font: Font, language: Language, -) -> Container<'static, Message, StyleType> { +) -> Container<'a, Message, StyleType> { let curr_threshold_str = &packets_notification.threshold.unwrap().to_string(); let input_row = Row::new() .align_y(Alignment::Center) @@ -293,11 +293,11 @@ fn input_group_packets( .align_y(Alignment::Center) } -fn input_group_bytes( +fn input_group_bytes<'a>( bytes_notification: BytesNotification, font: Font, language: Language, -) -> Container<'static, Message, StyleType> { +) -> Container<'a, Message, StyleType> { let info_str = format!( "{}; {}", per_second_translation(language), @@ -340,11 +340,11 @@ fn input_group_bytes( .align_y(Alignment::Center) } -fn volume_slider( +fn volume_slider<'a>( language: Language, font: Font, volume: u8, -) -> Container<'static, Message, StyleType> { +) -> Container<'a, Message, StyleType> { Container::new( Column::new() .spacing(5) @@ -380,11 +380,11 @@ fn volume_slider( .align_y(Alignment::Center) } -fn sound_buttons( +fn sound_buttons<'a>( notification: Notification, font: Font, language: Language, -) -> Row<'static, Message, StyleType> { +) -> Row<'a, Message, StyleType> { let current_sound = match notification { Notification::Packets(n) => n.sound, Notification::Bytes(n) => n.sound, @@ -427,12 +427,12 @@ fn sound_buttons( ret_val } -pub fn settings_header( +pub fn settings_header<'a>( font: Font, font_headers: Font, color_gradient: GradientType, language: Language, -) -> Container<'static, Message, StyleType> { +) -> Container<'a, Message, StyleType> { Container::new( Row::new() .push(horizontal_space()) diff --git a/src/gui/pages/settings_style_page.rs b/src/gui/pages/settings_style_page.rs index 7ed134c0..ffaf36da 100644 --- a/src/gui/pages/settings_style_page.rs +++ b/src/gui/pages/settings_style_page.rs @@ -29,7 +29,7 @@ use crate::utils::types::icon::Icon; use crate::StyleType::{Day, DeepSea, MonAmour, Night}; use crate::{ConfigSettings, Language, Sniffer, StyleType}; -pub fn settings_style_page(sniffer: &Sniffer) -> Container { +pub fn settings_style_page<'a>(sniffer: &Sniffer) -> Container<'a, Message, StyleType> { let ConfigSettings { style, language, @@ -119,11 +119,11 @@ pub fn settings_style_page(sniffer: &Sniffer) -> Container { .class(ContainerType::Modal) } -fn gradients_row( +fn gradients_row<'a>( font: Font, color_gradient: GradientType, language: Language, -) -> Row<'static, Message, StyleType> { +) -> Row<'a, Message, StyleType> { Row::new() .align_y(Alignment::Center) .spacing(10) @@ -181,12 +181,12 @@ fn gradients_row( ) } -fn get_palette_container( +fn get_palette_container<'a>( style: StyleType, name: String, description: String, on_press: StyleType, -) -> Button<'static, Message, StyleType> { +) -> Button<'a, Message, StyleType> { let font = style.get_extension().font; let is_custom = matches!(on_press, StyleType::Custom(_)); @@ -218,11 +218,11 @@ fn get_palette_container( .on_press(Message::Style(on_press)) } -fn get_palette_rule( +fn get_palette_rule<'a>( palette: Palette, buttons_color: Color, is_custom: bool, -) -> Container<'static, Message, StyleType> { +) -> Container<'a, Message, StyleType> { let height = if is_custom { 25 } else { 40 }; Container::new( @@ -251,7 +251,7 @@ fn get_palette_rule( fn get_extra_palettes( styles: &[ExtraStyles], current_style: StyleType, -) -> Vec> { +) -> Vec> { // Map each extra style into a palette container let mut styles = styles.iter().map(|&style| { let name = style.to_string(); @@ -293,7 +293,7 @@ fn lazy_custom_style_input( font: Font, custom_path: &str, style: StyleType, -) -> Button<'static, Message, StyleType> { +) -> Button { let is_custom_toml_style_set = matches!(style, StyleType::Custom(ExtraStyles::CustomToml(_))); let custom_palette = Palette::from_file(custom_path); diff --git a/src/gui/pages/thumbnail_page.rs b/src/gui/pages/thumbnail_page.rs index e3e2c1b6..0aac34e1 100644 --- a/src/gui/pages/thumbnail_page.rs +++ b/src/gui/pages/thumbnail_page.rs @@ -23,7 +23,7 @@ const MAX_CHARS_HOST: usize = 26; const MAX_CHARS_SERVICE: usize = 13; /// Computes the body of the thumbnail view -pub fn thumbnail_page(sniffer: &Sniffer) -> Container { +pub fn thumbnail_page<'a>(sniffer: &'a Sniffer) -> Container<'a, Message, StyleType> { let ConfigSettings { style, .. } = sniffer.configs.lock().unwrap().settings; let font = style.get_extension().font; @@ -60,11 +60,11 @@ pub fn thumbnail_page(sniffer: &Sniffer) -> Container { Container::new(content) } -fn host_col( +fn host_col<'a>( info_traffic: &Arc>, chart_type: ChartType, font: Font, -) -> Column<'static, Message, StyleType> { +) -> Column<'a, Message, StyleType> { let mut host_col = Column::new() .padding([0, 5]) .spacing(3) @@ -102,11 +102,11 @@ fn host_col( host_col } -fn service_col( +fn service_col<'a>( info_traffic: &Arc>, chart_type: ChartType, font: Font, -) -> Column<'static, Message, StyleType> { +) -> Column<'a, Message, StyleType> { let mut service_col = Column::new().padding([0, 5]).spacing(3).width(Length::Fill); let services = get_service_entries(info_traffic, chart_type, SortType::Neutral); let n_entry = min(services.len(), MAX_ENTRIES); diff --git a/src/gui/pages/types/running_page.rs b/src/gui/pages/types/running_page.rs index 23a84979..a37817c8 100644 --- a/src/gui/pages/types/running_page.rs +++ b/src/gui/pages/types/running_page.rs @@ -51,7 +51,7 @@ impl RunningPage { } } - pub fn icon(self) -> iced::widget::Text<'static, StyleType> { + pub fn icon<'a>(self) -> iced::widget::Text<'a, StyleType> { match self { RunningPage::Overview => Icon::Overview, RunningPage::Inspect => Icon::Inspect, diff --git a/src/gui/pages/types/settings_page.rs b/src/gui/pages/types/settings_page.rs index 969ba4c6..2dbaf9ca 100644 --- a/src/gui/pages/types/settings_page.rs +++ b/src/gui/pages/types/settings_page.rs @@ -46,7 +46,7 @@ impl SettingsPage { } } - pub fn icon(self) -> iced::widget::Text<'static, StyleType> { + pub fn icon<'a>(self) -> iced::widget::Text<'a, StyleType> { match self { SettingsPage::Notifications => Icon::Notification, SettingsPage::Appearance => Icon::HalfSun, diff --git a/src/gui/sniffer.rs b/src/gui/sniffer.rs index 0e136d93..33a03c6f 100644 --- a/src/gui/sniffer.rs +++ b/src/gui/sniffer.rs @@ -556,7 +556,7 @@ impl Sniffer { color_gradient, font, font_headers, - &self.newer_release_available.clone(), + self.newer_release_available.clone(), ); let content = Column::new().push(header).push(body).push(footer); diff --git a/src/gui/styles/text.rs b/src/gui/styles/text.rs index 7ad48654..fddcc443 100644 --- a/src/gui/styles/text.rs +++ b/src/gui/styles/text.rs @@ -24,11 +24,11 @@ pub enum TextType { /// Returns a formatted caption followed by subtitle, new line, tab, and desc impl TextType { - pub fn highlighted_subtitle_with_desc( + pub fn highlighted_subtitle_with_desc<'a>( subtitle: &str, desc: &str, font: Font, - ) -> Column<'static, Message, StyleType> { + ) -> Column<'a, Message, StyleType> { Column::new() .push( Text::new(format!("{subtitle}:")) diff --git a/src/networking/types/my_link_type.rs b/src/networking/types/my_link_type.rs index 11164a45..818b46c0 100644 --- a/src/networking/types/my_link_type.rs +++ b/src/networking/types/my_link_type.rs @@ -58,11 +58,11 @@ impl MyLinkType { } } - pub fn link_type_col( + pub fn link_type_col<'a>( self, language: Language, font: Font, - ) -> Column<'static, Message, StyleType> { + ) -> Column<'a, Message, StyleType> { match self { Self::Null(l) | Self::Ethernet(l) diff --git a/src/notifications/types/sound.rs b/src/notifications/types/sound.rs index 7afd0dc8..ea05de6b 100644 --- a/src/notifications/types/sound.rs +++ b/src/notifications/types/sound.rs @@ -42,7 +42,7 @@ impl Sound { } } - pub fn get_text(self, font: Font) -> iced::widget::Text<'static, StyleType> { + pub fn get_text<'a>(self, font: Font) -> iced::widget::Text<'a, StyleType> { match self { Sound::Gulp => Text::new("Gulp").font(font), Sound::Pop => Text::new("Pop").font(font), diff --git a/src/report/types/report_col.rs b/src/report/types/report_col.rs index bbcf4c6b..931d7bbd 100644 --- a/src/report/types/report_col.rs +++ b/src/report/types/report_col.rs @@ -17,7 +17,7 @@ const SMALL_COL_WIDTH: f32 = 95.0; const LARGE_COL_MAX_CHARS: usize = 25; const SMALL_COL_MAX_CHARS: usize = 10; -#[derive(Eq, PartialEq)] +#[derive(Eq, PartialEq, Copy, Clone)] pub enum ReportCol { SrcIp, SrcPort, diff --git a/src/report/types/report_sort_type.rs b/src/report/types/report_sort_type.rs index 4de73273..54a3b590 100644 --- a/src/report/types/report_sort_type.rs +++ b/src/report/types/report_sort_type.rs @@ -30,7 +30,7 @@ impl ReportSortType { } } - pub fn icon(self, report_col: &ReportCol) -> Text<'static, StyleType> { + pub fn icon<'a>(self, report_col: ReportCol) -> Text<'a, StyleType> { match report_col { ReportCol::Bytes => self.byte_sort.icon(), ReportCol::Packets => self.packet_sort.icon(), diff --git a/src/report/types/sort_type.rs b/src/report/types/sort_type.rs index ffb7216f..2dec0be5 100644 --- a/src/report/types/sort_type.rs +++ b/src/report/types/sort_type.rs @@ -21,7 +21,7 @@ impl SortType { } } - pub fn icon(self) -> Text<'static, StyleType> { + pub fn icon<'a>(self) -> Text<'a, StyleType> { let mut size = 14; match self { SortType::Ascending => Icon::SortAscending, diff --git a/src/translations/translations.rs b/src/translations/translations.rs index a61f3e84..47b2e2ad 100644 --- a/src/translations/translations.rs +++ b/src/translations/translations.rs @@ -5,7 +5,7 @@ use iced::widget::Text; use crate::translations::types::language::Language; use crate::StyleType; -pub fn choose_adapters_translation(language: Language) -> Text<'static, StyleType> { +pub fn choose_adapters_translation<'a>(language: Language) -> Text<'a, StyleType> { Text::new(match language { Language::EN => "Select network adapter to inspect", Language::IT => "Seleziona la scheda di rete da ispezionare", @@ -54,7 +54,7 @@ pub fn choose_adapters_translation(language: Language) -> Text<'static, StyleTyp // } // } -pub fn select_filters_translation(language: Language) -> Text<'static, StyleType> { +pub fn select_filters_translation<'a>(language: Language) -> Text<'a, StyleType> { Text::new(match language { Language::EN => "Select filters to be applied on network traffic", Language::IT => "Seleziona i filtri da applicare al traffico di rete", @@ -218,7 +218,7 @@ pub fn protocol_translation(language: Language) -> &'static str { } } -pub fn traffic_rate_translation(language: Language) -> Text<'static, StyleType> { +pub fn traffic_rate_translation<'a>(language: Language) -> Text<'a, StyleType> { Text::new(match language { Language::EN => "Traffic rate", Language::IT => "Intensità del traffico", @@ -243,7 +243,7 @@ pub fn traffic_rate_translation(language: Language) -> Text<'static, StyleType> }) } -// pub fn relevant_connections_translation(language: Language) -> Text<'static, StyleType> { +// pub fn relevant_connections_translation(language: Language) -> Text { // Text::new(match language { // Language::EN => "Relevant connections:", // Language::IT => "Connessioni rilevanti:", @@ -290,7 +290,7 @@ pub fn settings_translation(language: Language) -> &'static str { } } -pub fn yes_translation(language: Language) -> Text<'static, StyleType> { +pub fn yes_translation<'a>(language: Language) -> Text<'a, StyleType> { Text::new(match language { Language::EN => "Yes", Language::IT => "Sì", @@ -314,7 +314,7 @@ pub fn yes_translation(language: Language) -> Text<'static, StyleType> { }) } -pub fn ask_quit_translation(language: Language) -> Text<'static, StyleType> { +pub fn ask_quit_translation<'a>(language: Language) -> Text<'a, StyleType> { Text::new(match language { Language::EN => "Are you sure you want to quit this analysis?", Language::IT => "Sei sicuro di voler interrompere questa analisi?", @@ -364,7 +364,7 @@ pub fn quit_analysis_translation(language: Language) -> &'static str { } } -pub fn ask_clear_all_translation(language: Language) -> Text<'static, StyleType> { +pub fn ask_clear_all_translation<'a>(language: Language) -> Text<'a, StyleType> { Text::new(match language { Language::EN => "Are you sure you want to clear notifications?", Language::IT => "Sei sicuro di voler eliminare le notifiche?", @@ -463,7 +463,7 @@ pub fn network_adapter_translation(language: Language) -> &'static str { } } -pub fn no_addresses_translation(language: Language, adapter: &str) -> Text<'static, StyleType> { +pub fn no_addresses_translation<'a>(language: Language, adapter: &str) -> Text<'a, StyleType> { let network_adapter_translation = network_adapter_translation(language); Text::new(match language { Language::EN => format!("No traffic can be observed because the adapter you selected has no active addresses...\n\n\ @@ -529,7 +529,7 @@ pub fn no_addresses_translation(language: Language, adapter: &str) -> Text<'stat }) } -pub fn waiting_translation(language: Language, adapter: &str) -> Text<'static, StyleType> { +pub fn waiting_translation<'a>(language: Language, adapter: &str) -> Text<'a, StyleType> { let network_adapter_translation = network_adapter_translation(language); Text::new(match language { Language::EN => format!("No traffic has been observed yet. Waiting for network packets...\n\n\ @@ -596,7 +596,7 @@ pub fn waiting_translation(language: Language, adapter: &str) -> Text<'static, S }) } -pub fn some_observed_translation(language: Language, observed: u128) -> Text<'static, StyleType> { +pub fn some_observed_translation<'a>(language: Language, observed: u128) -> Text<'a, StyleType> { Text::new(match language { Language::EN => format!("Total intercepted packets: {observed}\n\n\ Filtered packets: 0\n\n\ @@ -772,7 +772,7 @@ pub fn of_total_translation(language: Language, percentage: &str) -> String { // }) // } -// pub fn no_favorites_translation(language: Language) -> Text<'static, StyleType> { +// pub fn no_favorites_translation(language: Language) -> Text { // Text::new(match language { // Language::EN => "Nothing to show at the moment.\n\ // To add a connection to your favorites, click on the star symbol near the connection.", @@ -811,7 +811,7 @@ pub fn of_total_translation(language: Language, percentage: &str) -> String { // }) // } -pub fn error_translation(language: Language, error: &str) -> Text<'static, StyleType> { +pub fn error_translation(language: Language, error: &str) -> Text { Text::new(match language { Language::EN => format!( "An error occurred! \n\n\ @@ -1144,7 +1144,7 @@ pub fn bytes_chart_translation(language: Language) -> &'static str { // } // } -pub fn notifications_title_translation(language: Language) -> Text<'static, StyleType> { +pub fn notifications_title_translation<'a>(language: Language) -> Text<'a, StyleType> { Text::new(match language { Language::EN => "Customize your notifications", Language::IT => "Personalizza le tue notifiche", @@ -1169,7 +1169,7 @@ pub fn notifications_title_translation(language: Language) -> Text<'static, Styl }) } -pub fn appearance_title_translation(language: Language) -> Text<'static, StyleType> { +pub fn appearance_title_translation<'a>(language: Language) -> Text<'a, StyleType> { Text::new(match language { Language::EN => "Choose your favorite theme", Language::IT => "Scegli il tuo tema preferito", @@ -1829,7 +1829,7 @@ pub fn favorite_transmitted_translation(language: Language) -> &'static str { } } -pub fn no_notifications_set_translation(language: Language) -> Text<'static, StyleType> { +pub fn no_notifications_set_translation<'a>(language: Language) -> Text<'a, StyleType> { Text::new(match language { Language::EN => "You haven't enabled notifications yet!\n\n\ After enabling them, this page will display a log of your notifications\n\n\ @@ -1894,7 +1894,7 @@ pub fn no_notifications_set_translation(language: Language) -> Text<'static, Sty }) } -pub fn no_notifications_received_translation(language: Language) -> Text<'static, StyleType> { +pub fn no_notifications_received_translation<'a>(language: Language) -> Text<'a, StyleType> { Text::new(match language { Language::EN => { "Nothing to see at the moment...\n\n\ diff --git a/src/translations/translations_3.rs b/src/translations/translations_3.rs index d4d4948f..42632b08 100644 --- a/src/translations/translations_3.rs +++ b/src/translations/translations_3.rs @@ -222,10 +222,10 @@ pub fn link_type_translation(language: Language) -> &'static str { } } -pub fn unsupported_link_type_translation( +pub fn unsupported_link_type_translation<'a>( language: Language, adapter: &str, -) -> Text<'static, StyleType> { +) -> Text<'a, StyleType> { let translation = match language { Language::EN => "The link type associated with this adapter is not supported by Sniffnet yet...", // Language::FA => "نوع پیوند مرتبط با این مبدل هنوز توسط Sniffnet پشتیبانی نمی شود...", diff --git a/src/translations/types/language.rs b/src/translations/types/language.rs index 87c765fe..5b3746b1 100644 --- a/src/translations/types/language.rs +++ b/src/translations/types/language.rs @@ -83,7 +83,7 @@ impl Language { Language::ZH, ]; - pub fn get_flag(self) -> Svg<'static, StyleType> { + pub fn get_flag<'a>(self) -> Svg<'a, StyleType> { Svg::new(Handle::from_memory(Vec::from(match self { Language::ZH => CN, Language::DE => DE, diff --git a/src/utils/types/icon.rs b/src/utils/types/icon.rs index eb15010d..7945c600 100644 --- a/src/utils/types/icon.rs +++ b/src/utils/types/icon.rs @@ -92,11 +92,11 @@ impl Icon { } } - pub fn to_text(&self) -> iced::widget::Text<'static, StyleType> { + pub fn to_text<'a>(&self) -> Text<'a, StyleType> { Text::new(self.codepoint().to_string()).font(ICONS) } - pub fn get_hourglass(num: usize) -> iced::widget::Text<'static, StyleType> { + pub fn get_hourglass<'a>(num: usize) -> Text<'a, StyleType> { match num { 1 => Icon::Hourglass1.to_text(), 2 => Icon::Hourglass2.to_text(),