mirror of
https://github.com/GyulyVGC/sniffnet.git
synced 2026-10-21 14:41:22 +00:00
avoid Settings struct full clones when destructuring
This commit is contained in:
parent
d0e7be2bfa
commit
1b2a2fc32d
5 changed files with 19 additions and 26 deletions
|
|
@ -43,9 +43,9 @@ use std::cmp::max;
|
|||
pub fn notifications_page(sniffer: &Sniffer) -> Container<'_, Message, StyleType> {
|
||||
let Settings {
|
||||
language,
|
||||
notifications,
|
||||
ref notifications,
|
||||
..
|
||||
} = sniffer.conf.settings.clone();
|
||||
} = sniffer.conf.settings;
|
||||
|
||||
let mut tab_and_body = Column::new()
|
||||
.align_x(Alignment::Center)
|
||||
|
|
|
|||
|
|
@ -54,11 +54,11 @@ fn column_all_general_setting(sniffer: &Sniffer) -> Column<'_, Message, StyleTyp
|
|||
let Settings {
|
||||
language,
|
||||
scale_factor,
|
||||
mmdb_country,
|
||||
mmdb_asn,
|
||||
ip_blacklist: ip_blacklist_str,
|
||||
ref mmdb_country,
|
||||
ref mmdb_asn,
|
||||
ip_blacklist: ref ip_blacklist_str,
|
||||
..
|
||||
} = sniffer.conf.settings.clone();
|
||||
} = sniffer.conf.settings;
|
||||
let ip_blacklist = &sniffer.ip_blacklist;
|
||||
|
||||
let is_editable = sniffer.running_page.is_none();
|
||||
|
|
@ -86,14 +86,14 @@ fn column_all_general_setting(sniffer: &Sniffer) -> Column<'_, Message, StyleTyp
|
|||
.push(mmdb_settings(
|
||||
is_editable,
|
||||
language,
|
||||
&mmdb_country,
|
||||
&mmdb_asn,
|
||||
mmdb_country,
|
||||
mmdb_asn,
|
||||
&sniffer.mmdb_readers,
|
||||
))
|
||||
.push(RuleType::Standard.vertical(25))
|
||||
.push(blacklist_selection(
|
||||
is_editable,
|
||||
&ip_blacklist_str,
|
||||
ip_blacklist_str,
|
||||
ip_blacklist,
|
||||
language,
|
||||
));
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ use crate::gui::styles::style_constants::{FONT_SIZE_FOOTER, FONT_SIZE_SUBTITLE,
|
|||
use crate::gui::styles::text::TextType;
|
||||
use crate::gui::styles::types::gradient_type::GradientType;
|
||||
use crate::gui::types::message::Message;
|
||||
use crate::gui::types::settings::Settings;
|
||||
use crate::networking::types::data_representation::DataRepr;
|
||||
use crate::notifications::types::notifications::{
|
||||
DataNotification, Notification, RemoteNotifications, SimpleNotification,
|
||||
|
|
@ -35,12 +34,9 @@ use crate::{Language, Sniffer, StyleType};
|
|||
const CONTAINERS_WIDTH: f32 = 715.0;
|
||||
|
||||
pub fn settings_notifications_page<'a>(sniffer: &Sniffer) -> Container<'a, Message, StyleType> {
|
||||
let Settings {
|
||||
language,
|
||||
color_gradient,
|
||||
mut notifications,
|
||||
..
|
||||
} = sniffer.conf.settings.clone();
|
||||
let language = sniffer.conf.settings.language;
|
||||
let color_gradient = sniffer.conf.settings.color_gradient;
|
||||
let mut notifications = sniffer.conf.settings.notifications.clone();
|
||||
|
||||
// Use threshold that has not yet been applied, if available
|
||||
if let Some(temp_data_notification) = sniffer.timing_events.temp_threshold() {
|
||||
|
|
|
|||
|
|
@ -31,9 +31,9 @@ pub fn settings_style_page(sniffer: &Sniffer) -> Container<'_, Message, StyleTyp
|
|||
style,
|
||||
language,
|
||||
color_gradient,
|
||||
style_path,
|
||||
ref style_path,
|
||||
..
|
||||
} = sniffer.conf.settings.clone();
|
||||
} = sniffer.conf.settings;
|
||||
|
||||
let mut content = Column::new()
|
||||
.align_x(Alignment::Center)
|
||||
|
|
@ -56,7 +56,7 @@ pub fn settings_style_page(sniffer: &Sniffer) -> Container<'_, Message, StyleTyp
|
|||
}
|
||||
styles_col = styles_col
|
||||
.push(lazy((language, style_path.clone(), style), move |_| {
|
||||
lazy_custom_style_input(language, &style_path, style)
|
||||
lazy_custom_style_input(language, style_path, style)
|
||||
}))
|
||||
.push(Space::new().height(10));
|
||||
|
||||
|
|
|
|||
|
|
@ -147,13 +147,10 @@ pub struct Sniffer {
|
|||
|
||||
impl Sniffer {
|
||||
pub fn new(conf: Conf) -> Self {
|
||||
let Settings {
|
||||
style,
|
||||
language,
|
||||
mmdb_country,
|
||||
mmdb_asn,
|
||||
..
|
||||
} = conf.settings.clone();
|
||||
let style = conf.settings.style;
|
||||
let language = conf.settings.language;
|
||||
let mmdb_country = conf.settings.mmdb_country.clone();
|
||||
let mmdb_asn = conf.settings.mmdb_asn.clone();
|
||||
let data_repr = conf.data_repr;
|
||||
let capture_source = CaptureSource::from_conf(&conf);
|
||||
let preview_charts = pcap::Device::list()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue