Debian Codegraph @

src/collection.rs

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 //! This is the main file to house data collection functions.
2 //!
3 //! TODO: Rename this to intake? Collection?
4
5 #[cfg(feature = "nvidia")]
6 pub mod nvidiarust-analyzer cargo bottom 0.14.9 collection/nvidia/;
7
8 #[cfg(all(target_os = "linux", feature = "gpu"))]
9 pub mod amdrust-analyzer cargo bottom 0.14.9 collection/amd/;
10
11 #[cfg(target_os = "linux")]
12 mod linuxrust-analyzer cargo bottom 0.14.9 collection/linux/ {
13 pub mod cgroupsrust-analyzer cargo bottom 0.14.9 collection/linux/cgroups/;
14 pub mod utilsrust-analyzer cargo bottom 0.14.9 collection/linux/utils/;
15 }
16
17 #[cfg(feature = "battery")]
18 pub mod batteriesrust-analyzer cargo bottom 0.14.9 collection/batteries/;
19 pub mod cpurust-analyzer cargo bottom 0.14.9 collection/cpu/;
20 pub mod disksrust-analyzer cargo bottom 0.14.9 collection/disks/;
21 pub mod errorrust-analyzer cargo bottom 0.14.9 collection/error/;
22 pub mod memoryrust-analyzer cargo bottom 0.14.9 collection/memory/;
23 pub mod networkrust-analyzer cargo bottom 0.14.9 collection/network/;
24 pub mod processesrust-analyzer cargo bottom 0.14.9 collection/processes/;
25 pub mod temperaturerust-analyzer cargo bottom 0.14.9 collection/temperature/;
26
27 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::{Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#, Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#};
28
29 #[cfg(any(not(target_os = "windows"), feature = "gpu"))]
30 use processesrust-analyzer cargo bottom 0.14.9 collection/processes/::Pidrust-analyzer cargo bottom 0.14.9 collection/processes/Pid#;
31 #[cfg(feature = "battery")]
32 use starship_batteryrust-analyzer cargo starship-battery 0.11.1 crate/::{Batteryrust-analyzer cargo starship-battery 0.11.1 types/battery/Battery#, Managerrust-analyzer cargo starship-battery 0.11.1 types/manager/Manager#};
33
34 use superrust-analyzer cargo bottom 0.14.9 crate/::DataFiltersrust-analyzer cargo bottom 0.14.9 app/DataFilters#;
35 use craterust-analyzer cargo bottom 0.14.9 crate/::apprust-analyzer cargo bottom 0.14.9 app/::layout_managerrust-analyzer cargo bottom 0.14.9 app/layout_manager/::UsedWidgetsrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#;
36 #[cfg(target_os = "linux")]
37 use craterust-analyzer cargo bottom 0.14.9 crate/::collectionrust-analyzer cargo bottom 0.14.9 collection/::linuxrust-analyzer cargo bottom 0.14.9 collection/linux/::cgroupsrust-analyzer cargo bottom 0.14.9 collection/linux/cgroups/::{CgroupCpuCollectorrust-analyzer cargo bottom 0.14.9 collection/linux/cgroups/CgroupCpuCollector#, CgroupMemCollectorrust-analyzer cargo bottom 0.14.9 collection/linux/cgroups/CgroupMemCollector#};
38 #[cfg(any(target_os = "linux", feature = "gpu"))]
39 use craterust-analyzer cargo bottom 0.14.9 crate/::utilsrust-analyzer cargo bottom 0.14.9 utils/::int_hashrust-analyzer cargo bottom 0.14.9 utils/int_hash/::IntHashMaprust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHashMap#;
40
41 // TODO: We can possibly reuse an internal buffer for this to reduce allocs.
42 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
43 pub struct Datarust-analyzer cargo bottom 0.14.9 collection/Data# {
44 pub collection_timerust-analyzer cargo bottom 0.14.9 collection/Data#collection_time.: Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#,
45 pub cpurust-analyzer cargo bottom 0.14.9 collection/Data#cpu.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<cpurust-analyzer cargo bottom 0.14.9 collection/cpu/::CpuHarvestrust-analyzer cargo bottom 0.14.9 collection/cpu/CpuHarvest#>,
46 pub load_avgrust-analyzer cargo bottom 0.14.9 collection/Data#load_avg.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<cpurust-analyzer cargo bottom 0.14.9 collection/cpu/::LoadAvgHarvestrust-analyzer cargo bottom 0.14.9 collection/cpu/LoadAvgHarvest#>,
47 pub memoryrust-analyzer cargo bottom 0.14.9 collection/Data#memory.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<memoryrust-analyzer cargo bottom 0.14.9 collection/memory/::MemDatarust-analyzer cargo bottom 0.14.9 collection/memory/MemData#>,
48 #[cfg(not(target_os = "windows"))]
49 pub cacherust-analyzer cargo bottom 0.14.9 collection/Data#cache.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<memoryrust-analyzer cargo bottom 0.14.9 collection/memory/::MemDatarust-analyzer cargo bottom 0.14.9 collection/memory/MemData#>,
50 pub swaprust-analyzer cargo bottom 0.14.9 collection/Data#swap.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<memoryrust-analyzer cargo bottom 0.14.9 collection/memory/::MemDatarust-analyzer cargo bottom 0.14.9 collection/memory/MemData#>,
51 pub temperature_sensorsrust-analyzer cargo bottom 0.14.9 collection/Data#temperature_sensors.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<temperaturerust-analyzer cargo bottom 0.14.9 collection/temperature/::TempSensorDatarust-analyzer cargo bottom 0.14.9 collection/temperature/TempSensorData#>>,
52 pub networkrust-analyzer cargo bottom 0.14.9 collection/Data#network.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<networkrust-analyzer cargo bottom 0.14.9 collection/network/::NetworkHarvestrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#>,
53 pub list_of_processesrust-analyzer cargo bottom 0.14.9 collection/Data#list_of_processes.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<processesrust-analyzer cargo bottom 0.14.9 collection/processes/::ProcessHarvestrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#>>,
54 pub disksrust-analyzer cargo bottom 0.14.9 collection/Data#disks.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<disksrust-analyzer cargo bottom 0.14.9 collection/disks/::DiskHarvestrust-analyzer cargo bottom 0.14.9 collection/disks/DiskHarvest#>>,
55 pub iorust-analyzer cargo bottom 0.14.9 collection/Data#io.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<disksrust-analyzer cargo bottom 0.14.9 collection/disks/::IoHarvestrust-analyzer cargo bottom 0.14.9 collection/disks/IoHarvest#>,
56 #[cfg(feature = "battery")]
57 pub list_of_batteriesrust-analyzer cargo bottom 0.14.9 collection/Data#list_of_batteries.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<batteriesrust-analyzer cargo bottom 0.14.9 collection/batteries/::BatteryDatarust-analyzer cargo bottom 0.14.9 collection/batteries/BatteryData#>>,
58 #[cfg(feature = "zfs")]
59 pub arcrust-analyzer cargo bottom 0.14.9 collection/Data#arc.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<memoryrust-analyzer cargo bottom 0.14.9 collection/memory/::MemDatarust-analyzer cargo bottom 0.14.9 collection/memory/MemData#>,
60 #[cfg(feature = "gpu")]
61 pub gpurust-analyzer cargo bottom 0.14.9 collection/Data#gpu.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, memoryrust-analyzer cargo bottom 0.14.9 collection/memory/::MemDatarust-analyzer cargo bottom 0.14.9 collection/memory/MemData#)>>,
62 }
63
64 impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Datarust-analyzer cargo bottom 0.14.9 collection/Data# {
65 fn defaultrust-analyzer cargo bottom 0.14.9 collection/impl#[Data][Default]default().() -> Selfrust-analyzer cargo bottom 0.14.9 collection/impl#[Data][Default] {
66 Datarust-analyzer cargo bottom 0.14.9 collection/Data# {
67 collection_timerust-analyzer cargo bottom 0.14.9 collection/Data#collection_time.: Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#::nowrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant]now().(),
68 cpurust-analyzer cargo bottom 0.14.9 collection/Data#cpu.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
69 load_avgrust-analyzer cargo bottom 0.14.9 collection/Data#load_avg.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
70 memoryrust-analyzer cargo bottom 0.14.9 collection/Data#memory.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
71 #[cfg(not(target_os = "windows"))]
72 cacherust-analyzer cargo bottom 0.14.9 collection/Data#cache.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
73 swaprust-analyzer cargo bottom 0.14.9 collection/Data#swap.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
74 temperature_sensorsrust-analyzer cargo bottom 0.14.9 collection/Data#temperature_sensors.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
75 list_of_processesrust-analyzer cargo bottom 0.14.9 collection/Data#list_of_processes.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
76 disksrust-analyzer cargo bottom 0.14.9 collection/Data#disks.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
77 iorust-analyzer cargo bottom 0.14.9 collection/Data#io.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
78 networkrust-analyzer cargo bottom 0.14.9 collection/Data#network.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
79 #[cfg(feature = "battery")]
80 list_of_batteriesrust-analyzer cargo bottom 0.14.9 collection/Data#list_of_batteries.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
81 #[cfg(feature = "zfs")]
82 arcrust-analyzer cargo bottom 0.14.9 collection/Data#arc.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
83 #[cfg(feature = "gpu")]
84 gpurust-analyzer cargo bottom 0.14.9 collection/Data#gpu.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
85 }
86 }
87 }
88
89 impl Datarust-analyzer cargo bottom 0.14.9 collection/Data# {
90 pub fn cleanuprust-analyzer cargo bottom 0.14.9 collection/impl#[Data]cleanup().(&mut self) {
91 self.iorust-analyzer cargo bottom 0.14.9 collection/Data#io. = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
92 self.temperature_sensorsrust-analyzer cargo bottom 0.14.9 collection/Data#temperature_sensors. = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
93 self.list_of_processesrust-analyzer cargo bottom 0.14.9 collection/Data#list_of_processes. = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
94 self.disksrust-analyzer cargo bottom 0.14.9 collection/Data#disks. = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
95 self.memoryrust-analyzer cargo bottom 0.14.9 collection/Data#memory. = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
96 self.swaprust-analyzer cargo bottom 0.14.9 collection/Data#swap. = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
97 self.cpurust-analyzer cargo bottom 0.14.9 collection/Data#cpu. = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
98 self.load_avgrust-analyzer cargo bottom 0.14.9 collection/Data#load_avg. = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
99
100 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(network) = &mut self.networkrust-analyzer cargo bottom 0.14.9 collection/Data#network. {
101 network.first_run_cleanuprust-analyzer cargo bottom 0.14.9 collection/network/impl#[NetworkHarvest]first_run_cleanup().();
102 }
103 #[cfg(feature = "zfs")]
104 {
105 self.arcrust-analyzer cargo bottom 0.14.9 collection/Data#arc. = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
106 }
107 #[cfg(feature = "gpu")]
108 {
109 self.gpurust-analyzer cargo bottom 0.14.9 collection/Data#gpu. = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
110 }
111 }
112 }
113
114 /// A wrapper around the sysinfo data source. We use sysinfo for the following
115 /// data:
116 /// - CPU usage
117 /// - Memory usage
118 /// - Network usage
119 /// - Processes (non-Linux)
120 /// - Disk (anything outside of Linux, macOS, and FreeBSD)
121 /// - Temperatures (non-Linux)
122 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
123 pub struct SysinfoSourcerust-analyzer cargo bottom 0.14.9 collection/SysinfoSource# {
124 /// Handles CPU, memory, and processes.
125 pub(craterust-analyzer cargo bottom 0.14.9 crate/) systemrust-analyzer cargo bottom 0.14.9 collection/SysinfoSource#system.: sysinforust-analyzer cargo sysinfo 0.39.6 crate/::Systemrust-analyzer cargo sysinfo 0.39.6 common/system/System#,
126 pub(craterust-analyzer cargo bottom 0.14.9 crate/) networkrust-analyzer cargo bottom 0.14.9 collection/SysinfoSource#network.: sysinforust-analyzer cargo sysinfo 0.39.6 crate/::Networksrust-analyzer cargo sysinfo 0.39.6 common/network/Networks#,
127 #[cfg(not(target_os = "linux"))]
128 pub(craterust-analyzer cargo bottom 0.14.9 crate/) temps: sysinforust-analyzer cargo sysinfo 0.39.6 crate/::Componentsrust-analyzer cargo sysinfo 0.39.6 common/component/Components#,
129 #[cfg(not(any(target_os = "linux", target_os = "macos")))]
130 pub(craterust-analyzer cargo bottom 0.14.9 crate/) disks: sysinforust-analyzer cargo sysinfo 0.39.6 crate/::Disksrust-analyzer cargo sysinfo 0.39.6 common/disk/Disks#,
131 #[cfg(target_os = "windows")]
132 pub(craterust-analyzer cargo bottom 0.14.9 crate/) users: sysinforust-analyzer cargo sysinfo 0.39.6 crate/::Usersrust-analyzer cargo sysinfo 0.39.6 common/user/Users#,
133 }
134
135 impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for SysinfoSourcerust-analyzer cargo bottom 0.14.9 collection/SysinfoSource# {
136 fn defaultrust-analyzer cargo bottom 0.14.9 collection/impl#[SysinfoSource][Default]default().() -> Selfrust-analyzer cargo bottom 0.14.9 collection/impl#[SysinfoSource][Default] {
137 use sysinforust-analyzer cargo sysinfo 0.39.6 crate/::*;
138
139 Selfrust-analyzer cargo bottom 0.14.9 collection/impl#[SysinfoSource][Default] {
140 systemrust-analyzer cargo bottom 0.14.9 collection/SysinfoSource#system.: Systemrust-analyzer cargo sysinfo 0.39.6 common/system/System#::newrust-analyzer cargo sysinfo 0.39.6 common/system/impl#[System]new().(),
141 networkrust-analyzer cargo bottom 0.14.9 collection/SysinfoSource#network.: Networksrust-analyzer cargo sysinfo 0.39.6 common/network/Networks#::newrust-analyzer cargo sysinfo 0.39.6 common/network/impl#[Networks]new().(),
142 #[cfg(not(target_os = "linux"))]
143 temps: Componentsrust-analyzer cargo sysinfo 0.39.6 common/component/Components#::new(),
144 #[cfg(not(any(target_os = "linux", target_os = "macos")))]
145 disks: Disksrust-analyzer cargo sysinfo 0.39.6 common/disk/Disks#::new(),
146 #[cfg(target_os = "windows")]
147 users: Usersrust-analyzer cargo sysinfo 0.39.6 common/user/Users#::new(),
148 }
149 }
150 }
151
152 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
153 pub struct DataCollectorrust-analyzer cargo bottom 0.14.9 collection/DataCollector# {
154 pub datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data.: Datarust-analyzer cargo bottom 0.14.9 collection/Data#,
155 sysrust-analyzer cargo bottom 0.14.9 collection/DataCollector#sys.: SysinfoSourcerust-analyzer cargo bottom 0.14.9 collection/SysinfoSource#,
156 last_collection_timerust-analyzer cargo bottom 0.14.9 collection/DataCollector#last_collection_time.: Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#,
157 widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest.: UsedWidgetsrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#,
158 filtersrust-analyzer cargo bottom 0.14.9 collection/DataCollector#filters.: DataFiltersrust-analyzer cargo bottom 0.14.9 app/DataFilters#,
159 include_unmounted_disksrust-analyzer cargo bottom 0.14.9 collection/DataCollector#include_unmounted_disks.: bool,
160
161 total_rxrust-analyzer cargo bottom 0.14.9 collection/DataCollector#total_rx.: u64,
162 total_txrust-analyzer cargo bottom 0.14.9 collection/DataCollector#total_tx.: u64,
163 total_rx_packetsrust-analyzer cargo bottom 0.14.9 collection/DataCollector#total_rx_packets.: u64,
164 total_tx_packetsrust-analyzer cargo bottom 0.14.9 collection/DataCollector#total_tx_packets.: u64,
165
166 unnormalized_cpurust-analyzer cargo bottom 0.14.9 collection/DataCollector#unnormalized_cpu.: bool,
167 use_current_cpu_totalrust-analyzer cargo bottom 0.14.9 collection/DataCollector#use_current_cpu_total.: bool,
168 show_average_cpurust-analyzer cargo bottom 0.14.9 collection/DataCollector#show_average_cpu.: bool,
169 get_process_threadsrust-analyzer cargo bottom 0.14.9 collection/DataCollector#get_process_threads.: bool,
170
171 last_list_collection_timerust-analyzer cargo bottom 0.14.9 collection/DataCollector#last_list_collection_time.: Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#,
172 should_run_less_routine_tasksrust-analyzer cargo bottom 0.14.9 collection/DataCollector#should_run_less_routine_tasks.: bool,
173
174 #[cfg(target_os = "linux")]
175 prev_process_detailsrust-analyzer cargo bottom 0.14.9 collection/DataCollector#prev_process_details.: IntHashMaprust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHashMap#<Pidrust-analyzer cargo bottom 0.14.9 collection/processes/Pid#, processesrust-analyzer cargo bottom 0.14.9 collection/processes/::PrevProcDetailsrust-analyzer cargo bottom 0.14.9 collection/processes/linux/PrevProcDetails#>,
176 #[cfg(target_os = "linux")]
177 prev_idlerust-analyzer cargo bottom 0.14.9 collection/DataCollector#prev_idle.: f64,
178 #[cfg(target_os = "linux")]
179 prev_non_idlerust-analyzer cargo bottom 0.14.9 collection/DataCollector#prev_non_idle.: f64,
180
181 #[cfg(feature = "battery")]
182 battery_managerrust-analyzer cargo bottom 0.14.9 collection/DataCollector#battery_manager.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Managerrust-analyzer cargo starship-battery 0.11.1 types/manager/Manager#>,
183 #[cfg(feature = "battery")]
184 battery_listrust-analyzer cargo bottom 0.14.9 collection/DataCollector#battery_list.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Batteryrust-analyzer cargo starship-battery 0.11.1 types/battery/Battery#>>,
185
186 #[cfg(unix)]
187 user_tablerust-analyzer cargo bottom 0.14.9 collection/DataCollector#user_table.: processesrust-analyzer cargo bottom 0.14.9 collection/processes/::UserTablerust-analyzer cargo bottom 0.14.9 collection/processes/unix/user_table/UserTable#,
188
189 #[cfg(feature = "gpu")]
190 gpu_pidsrust-analyzer cargo bottom 0.14.9 collection/DataCollector#gpu_pids.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<IntHashMaprust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHashMap#<Pidrust-analyzer cargo bottom 0.14.9 collection/processes/Pid#, (u64, u32)>>>,
191 #[cfg(feature = "gpu")]
192 gpus_total_memrust-analyzer cargo bottom 0.14.9 collection/DataCollector#gpus_total_mem.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u64>,
193 #[cfg(feature = "zfs")]
194 free_arc_memrust-analyzer cargo bottom 0.14.9 collection/DataCollector#free_arc_mem.: bool,
195
196 #[cfg(target_os = "linux")]
197 cgroup_memory_datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#cgroup_memory_data.: CgroupMemCollectorrust-analyzer cargo bottom 0.14.9 collection/linux/cgroups/CgroupMemCollector#,
198
199 #[cfg(target_os = "linux")]
200 cgroup_cpu_datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#cgroup_cpu_data.: CgroupCpuCollectorrust-analyzer cargo bottom 0.14.9 collection/linux/cgroups/CgroupCpuCollector#,
201 }
202
203 const LESS_ROUTINE_TASK_TIMErust-analyzer cargo bottom 0.14.9 collection/LESS_ROUTINE_TASK_TIME.: Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration# = Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_secsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_secs().(60);
204
205 impl DataCollectorrust-analyzer cargo bottom 0.14.9 collection/DataCollector# {
206 pub fn newrust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]new().(filters: DataFiltersrust-analyzer cargo bottom 0.14.9 app/DataFilters#) -> Selfrust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector] {
207 // Initialize it to the past to force it to load on initialization.
208 let now = Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#::nowrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant]now().();
209 let last_collection_time = now.checked_subrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant]checked_sub().(LESS_ROUTINE_TASK_TIMErust-analyzer cargo bottom 0.14.9 collection/LESS_ROUTINE_TASK_TIME. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration][`Mul<u32>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration][`Mul<u32>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration][`Mul<u32>`]mul().10).unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(now);
210
211 DataCollectorrust-analyzer cargo bottom 0.14.9 collection/DataCollector# {
212 datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data.: Datarust-analyzer cargo bottom 0.14.9 collection/Data#::defaultrust-analyzer cargo bottom 0.14.9 collection/impl#[Data][Default]default().(),
213 sysrust-analyzer cargo bottom 0.14.9 collection/DataCollector#sys.: SysinfoSourcerust-analyzer cargo bottom 0.14.9 collection/SysinfoSource#::defaultrust-analyzer cargo bottom 0.14.9 collection/impl#[SysinfoSource][Default]default().(),
214 #[cfg(target_os = "linux")]
215 prev_process_detailsrust-analyzer cargo bottom 0.14.9 collection/DataCollector#prev_process_details.: IntHashMaprust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHashMap#::defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`][Default]default().(),
216 #[cfg(target_os = "linux")]
217 prev_idlerust-analyzer cargo bottom 0.14.9 collection/DataCollector#prev_idle.: 0_f64,
218 #[cfg(target_os = "linux")]
219 prev_non_idlerust-analyzer cargo bottom 0.14.9 collection/DataCollector#prev_non_idle.: 0_f64,
220 use_current_cpu_totalrust-analyzer cargo bottom 0.14.9 collection/DataCollector#use_current_cpu_total.: false,
221 unnormalized_cpurust-analyzer cargo bottom 0.14.9 collection/DataCollector#unnormalized_cpu.: false,
222 get_process_threadsrust-analyzer cargo bottom 0.14.9 collection/DataCollector#get_process_threads.: false,
223 last_collection_timerust-analyzer cargo bottom 0.14.9 collection/DataCollector#last_collection_time.,
224 total_rxrust-analyzer cargo bottom 0.14.9 collection/DataCollector#total_rx.: 0,
225 total_txrust-analyzer cargo bottom 0.14.9 collection/DataCollector#total_tx.: 0,
226 total_rx_packetsrust-analyzer cargo bottom 0.14.9 collection/DataCollector#total_rx_packets.: 0,
227 total_tx_packetsrust-analyzer cargo bottom 0.14.9 collection/DataCollector#total_tx_packets.: 0,
228 show_average_cpurust-analyzer cargo bottom 0.14.9 collection/DataCollector#show_average_cpu.: false,
229 widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest.: UsedWidgetsrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#::defaultrust-analyzer cargo bottom 0.14.9 app/layout_manager/impl#[UsedWidgets][Default]default().(),
230 #[cfg(feature = "battery")]
231 battery_managerrust-analyzer cargo bottom 0.14.9 collection/DataCollector#battery_manager.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
232 #[cfg(feature = "battery")]
233 battery_listrust-analyzer cargo bottom 0.14.9 collection/DataCollector#battery_list.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
234 filtersrust-analyzer cargo bottom 0.14.9 collection/DataCollector#filters.,
235 #[cfg(unix)]
236 user_tablerust-analyzer cargo bottom 0.14.9 collection/DataCollector#user_table.: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo bottom 0.14.9 collection/processes/unix/user_table/impl#[UserTable][Default]default().(),
237 #[cfg(feature = "gpu")]
238 gpu_pidsrust-analyzer cargo bottom 0.14.9 collection/DataCollector#gpu_pids.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
239 #[cfg(feature = "gpu")]
240 gpus_total_memrust-analyzer cargo bottom 0.14.9 collection/DataCollector#gpus_total_mem.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
241 #[cfg(feature = "zfs")]
242 free_arc_memrust-analyzer cargo bottom 0.14.9 collection/DataCollector#free_arc_mem.: false,
243 last_list_collection_timerust-analyzer cargo bottom 0.14.9 collection/DataCollector#last_list_collection_time.: last_collection_time,
244 should_run_less_routine_tasksrust-analyzer cargo bottom 0.14.9 collection/DataCollector#should_run_less_routine_tasks.: true,
245 #[cfg(target_os = "linux")]
246 cgroup_memory_datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#cgroup_memory_data.: CgroupMemCollectorrust-analyzer cargo bottom 0.14.9 collection/linux/cgroups/CgroupMemCollector#::defaultrust-analyzer cargo bottom 0.14.9 collection/linux/cgroups/impl#[CgroupMemCollector][Default]default().(),
247 #[cfg(target_os = "linux")]
248 cgroup_cpu_datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#cgroup_cpu_data.: CgroupCpuCollectorrust-analyzer cargo bottom 0.14.9 collection/linux/cgroups/CgroupCpuCollector#::defaultrust-analyzer cargo bottom 0.14.9 collection/linux/cgroups/impl#[CgroupCpuCollector][Default]default().(),
249 include_unmounted_disksrust-analyzer cargo bottom 0.14.9 collection/DataCollector#include_unmounted_disks.: false,
250 }
251 }
252
253 /// Update the check for routine tasks like updating lists of batteries,
254 /// cleanup, etc. This is useful for things that we don't want to update
255 /// all the time.
256 ///
257 /// Note this should be set back to false if
258 /// `self.last_list_collection_time` is updated.
259 #[inline]
260 fn run_less_routine_tasksrust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]run_less_routine_tasks().(&mut self) {
261 if self
262 .datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data.
263 .collection_timerust-analyzer cargo bottom 0.14.9 collection/Data#collection_time.
264 .duration_sincerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant]duration_since().(self.last_list_collection_timerust-analyzer cargo bottom 0.14.9 collection/DataCollector#last_list_collection_time.)
265 >rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().LESS_ROUTINE_TASK_TIMErust-analyzer cargo bottom 0.14.9 collection/LESS_ROUTINE_TASK_TIME.
266 {
267 self.should_run_less_routine_tasksrust-analyzer cargo bottom 0.14.9 collection/DataCollector#should_run_less_routine_tasks. = true;
268 }
269
270 if self.should_run_less_routine_tasksrust-analyzer cargo bottom 0.14.9 collection/DataCollector#should_run_less_routine_tasks. {
271 self.last_list_collection_timerust-analyzer cargo bottom 0.14.9 collection/DataCollector#last_list_collection_time. = self.datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data..collection_timerust-analyzer cargo bottom 0.14.9 collection/Data#collection_time.;
272 }
273 }
274
275 pub fn set_collectionrust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]set_collection().(&mut self, used_widgets: UsedWidgetsrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#) {
276 self.widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest. = used_widgets;
277 }
278
279 pub fn set_use_current_cpu_totalrust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]set_use_current_cpu_total().(&mut self, use_current_cpu_total: bool) {
280 self.use_current_cpu_totalrust-analyzer cargo bottom 0.14.9 collection/DataCollector#use_current_cpu_total. = use_current_cpu_total;
281 }
282
283 pub fn set_unnormalized_cpurust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]set_unnormalized_cpu().(&mut self, unnormalized_cpu: bool) {
284 self.unnormalized_cpurust-analyzer cargo bottom 0.14.9 collection/DataCollector#unnormalized_cpu. = unnormalized_cpu;
285 }
286
287 pub fn set_show_average_cpurust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]set_show_average_cpu().(&mut self, show_average_cpu: bool) {
288 self.show_average_cpurust-analyzer cargo bottom 0.14.9 collection/DataCollector#show_average_cpu. = show_average_cpu;
289 }
290
291 pub fn set_get_process_threadsrust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]set_get_process_threads().(&mut self, get_process_threads: bool) {
292 self.get_process_threadsrust-analyzer cargo bottom 0.14.9 collection/DataCollector#get_process_threads. = get_process_threads;
293 }
294
295 pub fn set_include_unmounted_disksrust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]set_include_unmounted_disks().(&mut self, include_unmounted_disks: bool) {
296 self.include_unmounted_disksrust-analyzer cargo bottom 0.14.9 collection/DataCollector#include_unmounted_disks. = include_unmounted_disks;
297 }
298
299 #[cfg(feature = "zfs")]
300 pub fn set_free_arc_memrust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]set_free_arc_mem().(&mut self, free_mem: bool) {
301 self.free_arc_memrust-analyzer cargo bottom 0.14.9 collection/DataCollector#free_arc_mem. = free_mem;
302 }
303
304 /// Refresh sysinfo data. We use sysinfo for the following data:
305 /// - CPU usage
306 /// - Memory usage
307 /// - Network usage
308 /// - Processes (non-Linux)
309 /// - Disk (Windows, FreeBSD)
310 /// - Temperatures (non-Linux)
311 fn refresh_sysinfo_datarust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]refresh_sysinfo_data().(&mut self) {
312 // Refresh the list of objects once every minute. If it's too frequent it can
313 // cause segfaults.
314
315 if self.widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest..use_cpurust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_cpu. || self.widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest..use_procrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_proc. {
316 self.sysrust-analyzer cargo bottom 0.14.9 collection/DataCollector#sys..systemrust-analyzer cargo bottom 0.14.9 collection/SysinfoSource#system..refresh_cpu_allrust-analyzer cargo sysinfo 0.39.6 common/system/impl#[System]refresh_cpu_all().();
317 }
318
319 if self.widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest..use_memrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_mem. || self.widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest..use_procrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_proc. {
320 self.sysrust-analyzer cargo bottom 0.14.9 collection/DataCollector#sys..systemrust-analyzer cargo bottom 0.14.9 collection/SysinfoSource#system..refresh_memoryrust-analyzer cargo sysinfo 0.39.6 common/system/impl#[System]refresh_memory().();
321 }
322
323 if self.widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest..use_netrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_net. {
324 self.sysrust-analyzer cargo bottom 0.14.9 collection/DataCollector#sys..networkrust-analyzer cargo bottom 0.14.9 collection/SysinfoSource#network..refreshrust-analyzer cargo sysinfo 0.39.6 common/network/impl#[Networks]refresh().(true);
325 }
326
327 // sysinfo is used on non-Linux systems for the following:
328 // - Processes (users list as well for Windows)
329 // - Disks (Windows/FreeBSD)
330 // - Temperatures and temperature components list.
331 #[cfg(not(target_os = "linux"))]
332 {
333 if self.widgets_to_harvest.use_proc {
334 self.sys.system.refresh_processes_specifics(
335 sysinforust-analyzer cargo sysinfo 0.39.6 crate/::ProcessesToUpdaterust-analyzer cargo sysinfo 0.39.6 common/system/ProcessesToUpdate#::Allrust-analyzer cargo sysinfo 0.39.6 common/system/ProcessesToUpdate#All#,
336 true,
337 sysinforust-analyzer cargo sysinfo 0.39.6 crate/::ProcessRefreshKindrust-analyzer cargo sysinfo 0.39.6 common/system/ProcessRefreshKind#::everything()
338 .without_environ()
339 .without_cwd()
340 .without_root(),
341 );
342
343 // For Windows, sysinfo also handles the users list.
344 #[cfg(target_os = "windows")]
345 if self.should_run_less_routine_tasks {
346 self.sys.users.refresh();
347 }
348 }
349
350 if self.widgets_to_harvest.use_temp || self.widgets_to_harvest.use_temp_graph {
351 if self.should_run_less_routine_tasks {
352 self.sys.temps.refresh(true);
353 }
354
355 for component in self.sys.temps.iter_mut() {
356 component.refresh();
357 }
358 }
359
360 #[cfg(any(target_os = "windows", target_os = "freebsd"))]
361 if self.widgets_to_harvest.use_disk {
362 if self.should_run_less_routine_tasks {
363 self.sys.disks.refresh(true);
364 }
365
366 for disk in self.sys.disks.iter_mut() {
367 disk.refresh();
368 }
369 }
370 }
371 }
372
373 /// Update and refresh data.
374 ///
375 /// TODO: separate refresh steps and update steps
376 pub fn update_datarust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]update_data().(&mut self) {
377 self.datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data..collection_timerust-analyzer cargo bottom 0.14.9 collection/Data#collection_time. = Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#::nowrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant]now().();
378
379 self.run_less_routine_tasksrust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]run_less_routine_tasks().();
380
381 self.refresh_sysinfo_datarust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]refresh_sysinfo_data().();
382
383 #[cfg(target_os = "linux")]
384 {
385 let total_memory = self.sysrust-analyzer cargo bottom 0.14.9 collection/DataCollector#sys..systemrust-analyzer cargo bottom 0.14.9 collection/SysinfoSource#system..total_memoryrust-analyzer cargo sysinfo 0.39.6 common/system/impl#[System]total_memory().();
386 let total_swap = self.sysrust-analyzer cargo bottom 0.14.9 collection/DataCollector#sys..systemrust-analyzer cargo bottom 0.14.9 collection/SysinfoSource#system..total_swaprust-analyzer cargo sysinfo 0.39.6 common/system/impl#[System]total_swap().();
387 self.cgroup_memory_datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#cgroup_memory_data..refreshrust-analyzer cargo bottom 0.14.9 collection/linux/cgroups/impl#[CgroupMemCollector]refresh().(total_memory, total_swap);
388 }
389
390 #[cfg(target_os = "linux")]
391 self.cgroup_cpu_datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#cgroup_cpu_data..refreshrust-analyzer cargo bottom 0.14.9 collection/linux/cgroups/impl#[CgroupCpuCollector]refresh().();
392
393 self.update_cpu_usagerust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]update_cpu_usage().();
394 self.update_memory_usagerust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]update_memory_usage().();
395 self.update_tempsrust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]update_temps().();
396
397 #[cfg(feature = "battery")]
398 self.update_batteriesrust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]update_batteries().();
399
400 #[cfg(feature = "gpu")]
401 self.update_gpusrust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]update_gpus().();
402
403 self.update_processesrust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]update_processes().();
404 self.update_network_usagerust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]update_network_usage().();
405 self.update_disksrust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]update_disks().();
406
407 // Make sure to run this to refresh the setting.
408 self.should_run_less_routine_tasksrust-analyzer cargo bottom 0.14.9 collection/DataCollector#should_run_less_routine_tasks. = false;
409
410 // Update times for future reference.
411 self.last_collection_timerust-analyzer cargo bottom 0.14.9 collection/DataCollector#last_collection_time. = self.datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data..collection_timerust-analyzer cargo bottom 0.14.9 collection/Data#collection_time.;
412 }
413
414 /// Gets GPU data. Note this will usually append to other previously
415 /// collected data fields at the moment.
416 #[cfg(feature = "gpu")]
417 #[inline]
418 fn update_gpusrust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]update_gpus().(&mut self) {
419 if self.widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest..use_gpurust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_gpu. {
420 let mut local_gpu: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, memoryrust-analyzer cargo bottom 0.14.9 collection/memory/::MemDatarust-analyzer cargo bottom 0.14.9 collection/memory/MemData#)> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
421 let mut local_gpu_pids: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<IntHashMaprust-analyzer cargo bottom 0.14.9 utils/int_hash/IntHashMap#<Pidrust-analyzer cargo bottom 0.14.9 collection/processes/Pid#, (u64, u32)>> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
422 let mut local_gpu_total_mem: u64 = 0;
423
424 #[cfg(feature = "nvidia")]
425 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(data) = nvidiarust-analyzer cargo bottom 0.14.9 collection/nvidia/::get_nvidia_vecsrust-analyzer cargo bottom 0.14.9 collection/nvidia/get_nvidia_vecs().(
426 &self.filtersrust-analyzer cargo bottom 0.14.9 collection/DataCollector#filters..temp_filterrust-analyzer cargo bottom 0.14.9 app/DataFilters#temp_filter.,
427 &self.filtersrust-analyzer cargo bottom 0.14.9 collection/DataCollector#filters..temp_graph_filterrust-analyzer cargo bottom 0.14.9 app/DataFilters#temp_graph_filter.,
428 &self.widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest.,
429 ) {
430 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(mut temp) = data.temperaturerust-analyzer cargo bottom 0.14.9 collection/nvidia/GpusData#temperature. {
431 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(sensors) = &mut self.datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data..temperature_sensorsrust-analyzer cargo bottom 0.14.9 collection/Data#temperature_sensors. {
432 sensors.appendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]append().(&mut temp);
433 } else {
434 self.datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data..temperature_sensorsrust-analyzer cargo bottom 0.14.9 collection/Data#temperature_sensors. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(temp);
435 }
436 }
437 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(mut mem) = data.memoryrust-analyzer cargo bottom 0.14.9 collection/nvidia/GpusData#memory. {
438 local_gpu.appendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]append().(&mut mem);
439 }
440 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(mut proc) = data.procsrust-analyzer cargo bottom 0.14.9 collection/nvidia/GpusData#procs. {
441 local_gpu_pids.appendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]append().(&mut proc.1);
442 local_gpu_total_mem rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().proc.0;
443 }
444 }
445
446 #[cfg(target_os = "linux")]
447 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(data) =
448 amdrust-analyzer cargo bottom 0.14.9 collection/amd/::get_amd_vecsrust-analyzer cargo bottom 0.14.9 collection/amd/get_amd_vecs().(&self.widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest., self.last_collection_timerust-analyzer cargo bottom 0.14.9 collection/DataCollector#last_collection_time.)
449 {
450 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(mut mem) = data.memoryrust-analyzer cargo bottom 0.14.9 collection/amd/AmdGpuData#memory. {
451 local_gpu.appendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]append().(&mut mem);
452 }
453 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(mut proc) = data.procsrust-analyzer cargo bottom 0.14.9 collection/amd/AmdGpuData#procs. {
454 local_gpu_pids.appendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]append().(&mut proc.1);
455 local_gpu_total_mem rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().proc.0;
456 }
457 }
458
459 self.datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data..gpurust-analyzer cargo bottom 0.14.9 collection/Data#gpu. = (!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().local_gpu.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().()).then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(local_gpu);
460 self.gpu_pidsrust-analyzer cargo bottom 0.14.9 collection/DataCollector#gpu_pids. = (!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().local_gpu_pids.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().()).then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(local_gpu_pids);
461 self.gpus_total_memrust-analyzer cargo bottom 0.14.9 collection/DataCollector#gpus_total_mem. = (local_gpu_total_mem rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().0).then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(local_gpu_total_mem);
462 }
463 }
464
465 #[inline]
466 fn update_cpu_usagerust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]update_cpu_usage().(&mut self) {
467 if self.widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest..use_cpurust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_cpu. {
468 self.datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data..cpurust-analyzer cargo bottom 0.14.9 collection/Data#cpu. = cpurust-analyzer cargo bottom 0.14.9 collection/cpu/::get_cpu_data_listrust-analyzer cargo bottom 0.14.9 collection/cpu/sysinfo/get_cpu_data_list().(self).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().();
469
470 #[cfg(unix)]
471 {
472 self.datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data..load_avgrust-analyzer cargo bottom 0.14.9 collection/Data#load_avg. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(cpurust-analyzer cargo bottom 0.14.9 collection/cpu/::get_load_avgrust-analyzer cargo bottom 0.14.9 collection/cpu/sysinfo/get_load_avg().());
473 }
474 }
475 }
476
477 #[inline]
478 fn update_processesrust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]update_processes().(&mut self) {
479 if self.widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest..use_procrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_proc.
480 && let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(mut process_list) = self.get_processesrust-analyzer cargo bottom 0.14.9 collection/processes/impl#[DataCollector]get_processes().()
481 {
482 // NB: To avoid duplicate sorts on rerenders/events, we sort the processes by
483 // PID here. We also want to avoid re-sorting *again* later on
484 // if we're sorting by PID, since we already did it here!
485 process_list.sort_unstable_by_keyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]sort_unstable_by_key().(|p| p.pidrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#pid.);
486 self.datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data..list_of_processesrust-analyzer cargo bottom 0.14.9 collection/Data#list_of_processes. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(process_list);
487 }
488 }
489
490 #[inline]
491 fn update_tempsrust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]update_temps().(&mut self) {
492 if self.widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest..use_temprust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_temp. || self.widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest..use_temp_graphrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_temp_graph. {
493 #[cfg(not(target_os = "linux"))]
494 if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(data) = temperaturerust-analyzer cargo bottom 0.14.9 collection/temperature/::get_temperature_datarust-analyzer cargo bottom 0.14.9 collection/temperature/linux/get_temperature_data().(
495 &self.sys.temps,
496 &self.filters.temp_filter,
497 &self.filters.temp_graph_filter,
498 ) {
499 self.data.temperature_sensors = data;
500 }
501
502 #[cfg(target_os = "linux")]
503 if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(data) = temperaturerust-analyzer cargo bottom 0.14.9 collection/temperature/::get_temperature_datarust-analyzer cargo bottom 0.14.9 collection/temperature/linux/get_temperature_data().(
504 &self.filtersrust-analyzer cargo bottom 0.14.9 collection/DataCollector#filters..temp_filterrust-analyzer cargo bottom 0.14.9 app/DataFilters#temp_filter.,
505 &self.filtersrust-analyzer cargo bottom 0.14.9 collection/DataCollector#filters..temp_graph_filterrust-analyzer cargo bottom 0.14.9 app/DataFilters#temp_graph_filter.,
506 ) {
507 self.datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data..temperature_sensorsrust-analyzer cargo bottom 0.14.9 collection/Data#temperature_sensors. = data;
508 }
509 }
510 }
511
512 #[inline]
513 fn update_memory_usagerust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]update_memory_usage().(&mut self) {
514 if self.widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest..use_memrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_mem. {
515 self.datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data..memoryrust-analyzer cargo bottom 0.14.9 collection/Data#memory. = memoryrust-analyzer cargo bottom 0.14.9 collection/memory/::get_ram_usagerust-analyzer cargo bottom 0.14.9 collection/memory/sysinfo/get_ram_usage().(self);
516
517 #[cfg(feature = "zfs")]
518 {
519 #[cfg(any(target_os = "linux", target_os = "freebsd"))]
520 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(arc) = memoryrust-analyzer cargo bottom 0.14.9 collection/memory/::arcrust-analyzer cargo bottom 0.14.9 collection/memory/arc/::get_arc_usagerust-analyzer cargo bottom 0.14.9 collection/memory/arc/get_arc_usage().() {
521 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(mem) = &mut self.datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data..memoryrust-analyzer cargo bottom 0.14.9 collection/Data#memory. {
522 if self.free_arc_memrust-analyzer cargo bottom 0.14.9 collection/DataCollector#free_arc_mem. {
523 if arc.0.used_bytesrust-analyzer cargo bottom 0.14.9 collection/memory/MemData#used_bytes. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().arc.1 {
524 #[cfg(target_os = "linux")]
525 {
526 // Keep arc min like htop; the subtraction below won't underflow because of
527 // the above check.
528 mem.used_bytesrust-analyzer cargo bottom 0.14.9 collection/memory/MemData#used_bytes. =
529 mem.used_bytesrust-analyzer cargo bottom 0.14.9 collection/memory/MemData#used_bytes..saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]saturating_sub().(arc.0.used_bytesrust-analyzer cargo bottom 0.14.9 collection/memory/MemData#used_bytes. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Sub<Self>`]sub().arc.1);
530 }
531 #[cfg(target_os = "freebsd")]
532 {
533 mem.used_bytes += arc.1; // sysinfo subtracts arc_size on freebsd
534 }
535 } else {
536 #[cfg(target_os = "freebsd")]
537 {
538 mem.used_bytes += arc.0.used_bytes;
539 }
540 }
541 } else {
542 #[cfg(target_os = "freebsd")]
543 {
544 mem.used_bytes += arc.0.used_bytes;
545 }
546 }
547 }
548
549 self.datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data..arcrust-analyzer cargo bottom 0.14.9 collection/Data#arc. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(arc.0);
550 }
551 }
552
553 #[cfg(not(target_os = "windows"))]
554 if self.widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest..use_cacherust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_cache. {
555 self.datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data..cacherust-analyzer cargo bottom 0.14.9 collection/Data#cache. = memoryrust-analyzer cargo bottom 0.14.9 collection/memory/::get_cache_usagerust-analyzer cargo bottom 0.14.9 collection/memory/sysinfo/get_cache_usage().(&self.sysrust-analyzer cargo bottom 0.14.9 collection/DataCollector#sys..systemrust-analyzer cargo bottom 0.14.9 collection/SysinfoSource#system.);
556 }
557
558 self.datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data..swaprust-analyzer cargo bottom 0.14.9 collection/Data#swap. = memoryrust-analyzer cargo bottom 0.14.9 collection/memory/::get_swap_usagerust-analyzer cargo bottom 0.14.9 collection/memory/sysinfo/get_swap_usage().(self);
559 }
560 }
561
562 #[inline]
563 fn update_network_usagerust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]update_network_usage().(&mut self) {
564 if self.widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest..use_netrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_net. {
565 let net_data = networkrust-analyzer cargo bottom 0.14.9 collection/network/::get_network_datarust-analyzer cargo bottom 0.14.9 collection/network/sysinfo/get_network_data().(
566 &self.sysrust-analyzer cargo bottom 0.14.9 collection/DataCollector#sys..networkrust-analyzer cargo bottom 0.14.9 collection/SysinfoSource#network.,
567 self.last_collection_timerust-analyzer cargo bottom 0.14.9 collection/DataCollector#last_collection_time.,
568 &mut self.total_rxrust-analyzer cargo bottom 0.14.9 collection/DataCollector#total_rx.,
569 &mut self.total_txrust-analyzer cargo bottom 0.14.9 collection/DataCollector#total_tx.,
570 &mut self.total_rx_packetsrust-analyzer cargo bottom 0.14.9 collection/DataCollector#total_rx_packets.,
571 &mut self.total_tx_packetsrust-analyzer cargo bottom 0.14.9 collection/DataCollector#total_tx_packets.,
572 self.datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data..collection_timerust-analyzer cargo bottom 0.14.9 collection/Data#collection_time.,
573 &self.filtersrust-analyzer cargo bottom 0.14.9 collection/DataCollector#filters..net_filterrust-analyzer cargo bottom 0.14.9 app/DataFilters#net_filter.,
574 );
575
576 self.total_rxrust-analyzer cargo bottom 0.14.9 collection/DataCollector#total_rx. = net_data.total_rxrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#total_rx.;
577 self.total_txrust-analyzer cargo bottom 0.14.9 collection/DataCollector#total_tx. = net_data.total_txrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#total_tx.;
578 self.total_rx_packetsrust-analyzer cargo bottom 0.14.9 collection/DataCollector#total_rx_packets. = net_data.total_rx_packetsrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#total_rx_packets.;
579 self.total_tx_packetsrust-analyzer cargo bottom 0.14.9 collection/DataCollector#total_tx_packets. = net_data.total_tx_packetsrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#total_tx_packets.;
580 self.datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data..networkrust-analyzer cargo bottom 0.14.9 collection/Data#network. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(net_data);
581 }
582 }
583
584 /// Update battery information.
585 ///
586 /// If the battery manager is not initialized, it will attempt to initialize
587 /// it if at least one battery is found.
588 ///
589 /// This function also refreshes the list of batteries if
590 /// `self.should_run_less_routine_tasks` is true.
591 #[inline]
592 #[cfg(feature = "battery")]
593 fn update_batteriesrust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]update_batteries().(&mut self) {
594 let battery_manager = match &self.battery_managerrust-analyzer cargo bottom 0.14.9 collection/DataCollector#battery_manager. {
595 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(manager) => {
596 // Also check if we need to refresh the list of batteries.
597 if self.should_run_less_routine_tasksrust-analyzer cargo bottom 0.14.9 collection/DataCollector#should_run_less_routine_tasks. {
598 let battery_list = manager
599 .batteriesrust-analyzer cargo starship-battery 0.11.1 types/manager/impl#[Manager]batteries().()
600 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|batteries| batteries.filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#::okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>());
601
602 if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(battery_list) = battery_list {
603 if battery_list.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
604 self.battery_listrust-analyzer cargo bottom 0.14.9 collection/DataCollector#battery_list. = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
605 } else {
606 self.battery_listrust-analyzer cargo bottom 0.14.9 collection/DataCollector#battery_list. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(battery_list);
607 }
608 } else {
609 self.battery_listrust-analyzer cargo bottom 0.14.9 collection/DataCollector#battery_list. = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
610 }
611 }
612
613 manager
614 }
615 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => {
616 if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(manager) = Managerrust-analyzer cargo starship-battery 0.11.1 types/manager/Manager#::newrust-analyzer cargo starship-battery 0.11.1 types/manager/impl#[Manager]new().() {
617 let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(batteries) = manager.batteriesrust-analyzer cargo starship-battery 0.11.1 types/manager/impl#[Manager]batteries().() else {
618 return;
619 };
620
621 let battery_list = batteries.filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#::okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>();
622
623 if battery_list.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
624 return;
625 }
626
627 self.battery_listrust-analyzer cargo bottom 0.14.9 collection/DataCollector#battery_list. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(battery_list);
628 self.battery_managerrust-analyzer cargo bottom 0.14.9 collection/DataCollector#battery_manager..insertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]insert().(manager)
629 } else {
630 return;
631 }
632 }
633 };
634
635 self.datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data..list_of_batteriesrust-analyzer cargo bottom 0.14.9 collection/Data#list_of_batteries. = self
636 .battery_listrust-analyzer cargo bottom 0.14.9 collection/DataCollector#battery_list.
637 .as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().()
638 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|battery_list| batteriesrust-analyzer cargo bottom 0.14.9 collection/batteries/::refresh_batteriesrust-analyzer cargo bottom 0.14.9 collection/batteries/refresh_batteries().(battery_manager, battery_list));
639 }
640
641 #[inline]
642 fn update_disksrust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]update_disks().(&mut self) {
643 if self.widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest..use_diskrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_disk. || self.widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest..use_disk_io_graphrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_disk_io_graph. {
644 self.datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data..disksrust-analyzer cargo bottom 0.14.9 collection/Data#disks. = disksrust-analyzer cargo bottom 0.14.9 collection/disks/::get_disk_usagerust-analyzer cargo bottom 0.14.9 collection/disks/unix/get_disk_usage().(self).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().();
645 self.datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data..iorust-analyzer cargo bottom 0.14.9 collection/Data#io. = disksrust-analyzer cargo bottom 0.14.9 collection/disks/::get_io_usagerust-analyzer cargo bottom 0.14.9 collection/disks/get_io_usage().(self).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().();
646 }
647 }
648
649 /// Returns the total memory of the system.
650 #[inline]
651 fn total_memoryrust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]total_memory().(&self) -> u64 {
652 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(memory) = &self.datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data..memoryrust-analyzer cargo bottom 0.14.9 collection/Data#memory. {
653 memory.total_bytesrust-analyzer cargo bottom 0.14.9 collection/memory/MemData#total_bytes..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]get().()
654 } else {
655 self.sysrust-analyzer cargo bottom 0.14.9 collection/DataCollector#sys..systemrust-analyzer cargo bottom 0.14.9 collection/SysinfoSource#system..total_memoryrust-analyzer cargo sysinfo 0.39.6 common/system/impl#[System]total_memory().()
656 }
657 }
658 }
659
660 #[cfg(target_os = "freebsd")]
661 /// Deserialize [libxo](https://www.freebsd.org/cgi/man.cgi?query=libxo&apropos=0&sektion=0&manpath=FreeBSD+13.1-RELEASE+and+Ports&arch=default&format=html) JSON data
662 fn deserialize_xo<T>(key: &str, data: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<T, stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#>
663 where
664 T: serderust-analyzer cargo serde 1.0.228 crate/::derust-analyzer cargo serde_core 1.0.228 de/::DeserializeOwnedrust-analyzer cargo serde_core 1.0.228 de/DeserializeOwned#,
665 {
666 let mut value: serde_json::Value = serde_json::from_slice(data)?;
667 value
668 .as_object_mut()
669 .and_then(|map| map.remove(key))
670 .ok_or_else(|| stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::other("key not found"))
671 .and_then(|val| serde_json::from_value(val).map_err(|err| err.into()))
672 }
673
674 #[cfg(test)]
675 mod testsrust-analyzer cargo bottom 0.14.9 collection/tests/ {
676 use superrust-analyzer cargo bottom 0.14.9 collection/::*;
677
678 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
679 fn test_data_collectionrust-analyzer cargo bottom 0.14.9 collection/tests/test_data_collection().() {
680 let mut collector = DataCollectorrust-analyzer cargo bottom 0.14.9 collection/DataCollector#::newrust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]new().(DataFiltersrust-analyzer cargo bottom 0.14.9 app/DataFilters# {
681 disk_filterrust-analyzer cargo bottom 0.14.9 app/DataFilters#disk_filter.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
682 mount_filterrust-analyzer cargo bottom 0.14.9 app/DataFilters#mount_filter.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
683 temp_filterrust-analyzer cargo bottom 0.14.9 app/DataFilters#temp_filter.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
684 temp_graph_filterrust-analyzer cargo bottom 0.14.9 app/DataFilters#temp_graph_filter.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
685 disk_io_graph_filterrust-analyzer cargo bottom 0.14.9 app/DataFilters#disk_io_graph_filter.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
686 net_filterrust-analyzer cargo bottom 0.14.9 app/DataFilters#net_filter.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
687 });
688
689 // #[cfg(feature = "battery")]
690 // {
691 // collector.widgets_to_harvest.use_battery = true;
692 // }
693
694 // #[cfg(feature = "zfs")]
695 // {
696 // collector.widgets_to_harvest.use_cache = true;
697 // }
698
699 // #[cfg(feature = "gpu")]
700 // {
701 // collector.widgets_to_harvest.use_gpu = true;
702 // }
703
704 collector.widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest..use_cpurust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_cpu. = true;
705 collector.widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest..use_diskrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_disk. = true;
706 collector.widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest..use_memrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_mem. = true;
707 collector.widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest..use_netrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_net. = true;
708 collector.widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest..use_procrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_proc. = true;
709 collector.widgets_to_harvestrust-analyzer cargo bottom 0.14.9 collection/DataCollector#widgets_to_harvest..use_temprust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_temp. = true;
710
711 collector.update_datarust-analyzer cargo bottom 0.14.9 collection/impl#[DataCollector]update_data().();
712
713 let data = collector.datarust-analyzer cargo bottom 0.14.9 collection/DataCollector#data.;
714
715 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().data.cpurust-analyzer cargo bottom 0.14.9 collection/Data#cpu..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
•716 // assert!(!data.disks.unwrap().is_empty());
717 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(data.memoryrust-analyzer cargo bottom 0.14.9 collection/Data#memory..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
718 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(data.networkrust-analyzer cargo bottom 0.14.9 collection/Data#network..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
719 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().data.list_of_processesrust-analyzer cargo bottom 0.14.9 collection/Data#list_of_processes..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
720 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(data.temperature_sensorsrust-analyzer cargo bottom 0.14.9 collection/Data#temperature_sensors..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
721 }
722 }