refactor: rename data harvesting fns to what archs/oses they support (#229)

Just a simple rename.
This commit is contained in:
Clement Tsang 2020-09-09 23:30:09 -04:00 committed by GitHub
parent c58b2c2bb9
commit 0c21cba189
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 28 additions and 31 deletions

View File

@ -212,7 +212,7 @@ impl DataCollector {
if let Ok(process_list) = if cfg!(target_os = "linux") { if let Ok(process_list) = if cfg!(target_os = "linux") {
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
{ {
processes::linux_get_processes_list( processes::linux_processes(
&mut self.prev_idle, &mut self.prev_idle,
&mut self.prev_non_idle, &mut self.prev_non_idle,
&mut self.pid_mapping, &mut self.pid_mapping,
@ -231,7 +231,7 @@ impl DataCollector {
} else { } else {
#[cfg(not(target_os = "linux"))] #[cfg(not(target_os = "linux"))]
{ {
processes::windows_macos_get_processes_list( processes::windows_macos_processes(
&self.sys, &self.sys,
self.use_current_cpu_total, self.use_current_cpu_total,
self.mem_total_kb, self.mem_total_kb,
@ -250,7 +250,7 @@ impl DataCollector {
let network_data_fut = { let network_data_fut = {
#[cfg(any(target_os = "windows", target_arch = "aarch64", target_arch = "arm"))] #[cfg(any(target_os = "windows", target_arch = "aarch64", target_arch = "arm"))]
{ {
network::get_sysinfo_network_data( network::arm_or_windows_network_data(
&self.sys, &self.sys,
self.last_collection_time, self.last_collection_time,
&mut self.total_rx, &mut self.total_rx,
@ -261,7 +261,7 @@ impl DataCollector {
} }
#[cfg(not(any(target_os = "windows", target_arch = "aarch64", target_arch = "arm")))] #[cfg(not(any(target_os = "windows", target_arch = "aarch64", target_arch = "arm")))]
{ {
network::get_heim_network_data( network::non_arm_or_windows_network_data(
self.last_collection_time, self.last_collection_time,
&mut self.total_rx, &mut self.total_rx,
&mut self.total_tx, &mut self.total_tx,
@ -273,51 +273,51 @@ impl DataCollector {
let mem_data_fut = { let mem_data_fut = {
#[cfg(any(target_arch = "aarch64", target_arch = "arm"))] #[cfg(any(target_arch = "aarch64", target_arch = "arm"))]
{ {
mem::get_sysinfo_mem_data_list(&self.sys, self.widgets_to_harvest.use_mem) mem::arm_mem_data(&self.sys, self.widgets_to_harvest.use_mem)
} }
#[cfg(not(any(target_arch = "aarch64", target_arch = "arm")))] #[cfg(not(any(target_arch = "aarch64", target_arch = "arm")))]
{ {
mem::get_heim_mem_data_list(self.widgets_to_harvest.use_mem) mem::non_arm_mem_data(self.widgets_to_harvest.use_mem)
} }
}; };
let swap_data_fut = { let swap_data_fut = {
#[cfg(any(target_arch = "aarch64", target_arch = "arm"))] #[cfg(any(target_arch = "aarch64", target_arch = "arm"))]
{ {
mem::get_sysinfo_swap_data_list(&self.sys, self.widgets_to_harvest.use_mem) mem::arm_swap_data(&self.sys, self.widgets_to_harvest.use_mem)
} }
#[cfg(not(any(target_arch = "aarch64", target_arch = "arm")))] #[cfg(not(any(target_arch = "aarch64", target_arch = "arm")))]
{ {
mem::get_heim_swap_data_list(self.widgets_to_harvest.use_mem) mem::non_arm_swap_data(self.widgets_to_harvest.use_mem)
} }
}; };
let disk_data_fut = { let disk_data_fut = {
#[cfg(any(target_arch = "aarch64", target_arch = "arm"))] #[cfg(any(target_arch = "aarch64", target_arch = "arm"))]
{ {
disks::get_sysinfo_disk_usage_list(&self.sys, self.widgets_to_harvest.use_disk) disks::arm_disk_usage(&self.sys, self.widgets_to_harvest.use_disk)
} }
#[cfg(not(any(target_arch = "aarch64", target_arch = "arm")))] #[cfg(not(any(target_arch = "aarch64", target_arch = "arm")))]
{ {
disks::get_heim_disk_usage_list(self.widgets_to_harvest.use_disk) disks::non_arm_disk_usage(self.widgets_to_harvest.use_disk)
} }
}; };
let disk_io_usage_fut = { let disk_io_usage_fut = {
#[cfg(any(target_arch = "aarch64", target_arch = "arm"))] #[cfg(any(target_arch = "aarch64", target_arch = "arm"))]
{ {
disks::get_sysinfo_io_usage_list(&self.sys, self.widgets_to_harvest.use_disk) disks::arm_io_usage(&self.sys, self.widgets_to_harvest.use_disk)
} }
#[cfg(not(any(target_arch = "aarch64", target_arch = "arm")))] #[cfg(not(any(target_arch = "aarch64", target_arch = "arm")))]
{ {
disks::get_heim_io_usage_list(false, self.widgets_to_harvest.use_disk) disks::non_arm_io_usage(false, self.widgets_to_harvest.use_disk)
} }
}; };
let temp_data_fut = { let temp_data_fut = {
#[cfg(any(not(target_os = "linux"), target_arch = "aarch64", target_arch = "arm"))] #[cfg(any(not(target_os = "linux"), target_arch = "aarch64", target_arch = "arm"))]
{ {
temperature::get_sysinfo_temperature_data( temperature::arm_and_non_linux_temperature_data(
&self.sys, &self.sys,
&self.temperature_type, &self.temperature_type,
self.widgets_to_harvest.use_temp, self.widgets_to_harvest.use_temp,
@ -330,7 +330,7 @@ impl DataCollector {
target_arch = "arm" target_arch = "arm"
)))] )))]
{ {
temperature::get_heim_temperature_data( temperature::linux_temperature_data(
&self.temperature_type, &self.temperature_type,
self.widgets_to_harvest.use_temp, self.widgets_to_harvest.use_temp,
) )

View File

@ -17,15 +17,13 @@ pub type IOHarvest = std::collections::HashMap<String, Option<IOData>>;
/// Meant for ARM use. /// Meant for ARM use.
#[cfg(any(target_arch = "aarch64", target_arch = "arm"))] #[cfg(any(target_arch = "aarch64", target_arch = "arm"))]
pub async fn get_sysinfo_io_usage_list( pub async fn arm_io_usage(
_sys: &sysinfo::System, _actually_get: bool, _sys: &sysinfo::System, _actually_get: bool,
) -> crate::utils::error::Result<Option<IOHarvest>> { ) -> crate::utils::error::Result<Option<IOHarvest>> {
let io_hash: std::collections::HashMap<String, Option<IOData>> = let io_hash: std::collections::HashMap<String, Option<IOData>> =
std::collections::HashMap::new(); std::collections::HashMap::new();
Ok(Some(io_hash)) Ok(Some(io_hash))
// TODO: Rename these functions to be like "get_arm_io_usage_list"
// TODO: Sysinfo disk I/O usage. // TODO: Sysinfo disk I/O usage.
// ...sadly, this cannot be done as of now (other than me writing my own), it requires further // ...sadly, this cannot be done as of now (other than me writing my own), it requires further
// work. See https://github.com/GuillaumeGomez/sysinfo/issues/304. // work. See https://github.com/GuillaumeGomez/sysinfo/issues/304.
@ -33,7 +31,7 @@ pub async fn get_sysinfo_io_usage_list(
/// Meant for ARM use. /// Meant for ARM use.
#[cfg(any(target_arch = "aarch64", target_arch = "arm"))] #[cfg(any(target_arch = "aarch64", target_arch = "arm"))]
pub async fn get_sysinfo_disk_usage_list( pub async fn arm_disk_usage(
sys: &sysinfo::System, actually_get: bool, sys: &sysinfo::System, actually_get: bool,
) -> crate::utils::error::Result<Option<Vec<DiskHarvest>>> { ) -> crate::utils::error::Result<Option<Vec<DiskHarvest>>> {
use sysinfo::{DiskExt, SystemExt}; use sysinfo::{DiskExt, SystemExt};
@ -60,7 +58,7 @@ pub async fn get_sysinfo_disk_usage_list(
} }
#[cfg(not(any(target_arch = "aarch64", target_arch = "arm")))] #[cfg(not(any(target_arch = "aarch64", target_arch = "arm")))]
pub async fn get_heim_io_usage_list( pub async fn non_arm_io_usage(
get_physical: bool, actually_get: bool, get_physical: bool, actually_get: bool,
) -> crate::utils::error::Result<Option<IOHarvest>> { ) -> crate::utils::error::Result<Option<IOHarvest>> {
use futures::stream::StreamExt; use futures::stream::StreamExt;
@ -105,7 +103,7 @@ pub async fn get_heim_io_usage_list(
} }
#[cfg(not(any(target_arch = "aarch64", target_arch = "arm")))] #[cfg(not(any(target_arch = "aarch64", target_arch = "arm")))]
pub async fn get_heim_disk_usage_list( pub async fn non_arm_disk_usage(
actually_get: bool, actually_get: bool,
) -> crate::utils::error::Result<Option<Vec<DiskHarvest>>> { ) -> crate::utils::error::Result<Option<Vec<DiskHarvest>>> {
use futures::stream::StreamExt; use futures::stream::StreamExt;

View File

@ -15,7 +15,7 @@ impl Default for MemHarvest {
/// Meant for ARM use. /// Meant for ARM use.
#[cfg(any(target_arch = "aarch64", target_arch = "arm"))] #[cfg(any(target_arch = "aarch64", target_arch = "arm"))]
pub async fn get_sysinfo_mem_data_list( pub async fn arm_mem_data(
sys: &sysinfo::System, actually_get: bool, sys: &sysinfo::System, actually_get: bool,
) -> crate::utils::error::Result<Option<MemHarvest>> { ) -> crate::utils::error::Result<Option<MemHarvest>> {
use sysinfo::SystemExt; use sysinfo::SystemExt;
@ -31,7 +31,7 @@ pub async fn get_sysinfo_mem_data_list(
/// Meant for ARM use. /// Meant for ARM use.
#[cfg(any(target_arch = "aarch64", target_arch = "arm"))] #[cfg(any(target_arch = "aarch64", target_arch = "arm"))]
pub async fn get_sysinfo_swap_data_list( pub async fn arm_swap_data(
sys: &sysinfo::System, actually_get: bool, sys: &sysinfo::System, actually_get: bool,
) -> crate::utils::error::Result<Option<MemHarvest>> { ) -> crate::utils::error::Result<Option<MemHarvest>> {
use sysinfo::SystemExt; use sysinfo::SystemExt;
@ -46,7 +46,7 @@ pub async fn get_sysinfo_swap_data_list(
} }
#[cfg(not(any(target_arch = "aarch64", target_arch = "arm")))] #[cfg(not(any(target_arch = "aarch64", target_arch = "arm")))]
pub async fn get_heim_mem_data_list( pub async fn non_arm_mem_data(
actually_get: bool, actually_get: bool,
) -> crate::utils::error::Result<Option<MemHarvest>> { ) -> crate::utils::error::Result<Option<MemHarvest>> {
if !actually_get { if !actually_get {
@ -65,7 +65,7 @@ pub async fn get_heim_mem_data_list(
} }
#[cfg(not(any(target_arch = "aarch64", target_arch = "arm")))] #[cfg(not(any(target_arch = "aarch64", target_arch = "arm")))]
pub async fn get_heim_swap_data_list( pub async fn non_arm_swap_data(
actually_get: bool, actually_get: bool,
) -> crate::utils::error::Result<Option<MemHarvest>> { ) -> crate::utils::error::Result<Option<MemHarvest>> {
if !actually_get { if !actually_get {

View File

@ -17,7 +17,7 @@ impl NetworkHarvest {
/// Meant for Windows and ARM use. /// Meant for Windows and ARM use.
#[cfg(any(target_os = "windows", target_arch = "aarch64", target_arch = "arm"))] #[cfg(any(target_os = "windows", target_arch = "aarch64", target_arch = "arm"))]
pub async fn get_sysinfo_network_data( pub async fn arm_or_windows_network_data(
sys: &sysinfo::System, prev_net_access_time: Instant, prev_net_rx: &mut u64, sys: &sysinfo::System, prev_net_access_time: Instant, prev_net_rx: &mut u64,
prev_net_tx: &mut u64, curr_time: Instant, actually_get: bool, prev_net_tx: &mut u64, curr_time: Instant, actually_get: bool,
) -> Option<NetworkHarvest> { ) -> Option<NetworkHarvest> {
@ -58,7 +58,7 @@ pub async fn get_sysinfo_network_data(
} }
#[cfg(not(any(target_os = "windows", target_arch = "aarch64", target_arch = "arm")))] #[cfg(not(any(target_os = "windows", target_arch = "aarch64", target_arch = "arm")))]
pub async fn get_heim_network_data( pub async fn non_arm_or_windows_network_data(
prev_net_access_time: Instant, prev_net_rx: &mut u64, prev_net_tx: &mut u64, prev_net_access_time: Instant, prev_net_rx: &mut u64, prev_net_tx: &mut u64,
curr_time: Instant, actually_get: bool, curr_time: Instant, actually_get: bool,
) -> Option<NetworkHarvest> { ) -> Option<NetworkHarvest> {

View File

@ -339,7 +339,7 @@ fn read_proc<S: core::hash::BuildHasher>(
} }
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
pub fn linux_get_processes_list( pub fn linux_processes(
prev_idle: &mut f64, prev_non_idle: &mut f64, prev_idle: &mut f64, prev_non_idle: &mut f64,
pid_mapping: &mut HashMap<Pid, PrevProcDetails, RandomState>, use_current_cpu_total: bool, pid_mapping: &mut HashMap<Pid, PrevProcDetails, RandomState>, use_current_cpu_total: bool,
time_difference_in_secs: u64, mem_total_kb: u64, page_file_kb: u64, time_difference_in_secs: u64, mem_total_kb: u64, page_file_kb: u64,
@ -379,7 +379,7 @@ pub fn linux_get_processes_list(
} }
#[cfg(not(target_os = "linux"))] #[cfg(not(target_os = "linux"))]
pub fn windows_macos_get_processes_list( pub fn windows_macos_processes(
sys: &System, use_current_cpu_total: bool, mem_total_kb: u64, sys: &System, use_current_cpu_total: bool, mem_total_kb: u64,
) -> crate::utils::error::Result<Vec<ProcessHarvest>> { ) -> crate::utils::error::Result<Vec<ProcessHarvest>> {
let mut process_vector: Vec<ProcessHarvest> = Vec::new(); let mut process_vector: Vec<ProcessHarvest> = Vec::new();

View File

@ -22,7 +22,7 @@ impl Default for TemperatureType {
/// Meant for ARM and non-Linux usage. /// Meant for ARM and non-Linux usage.
#[cfg(any(not(target_os = "linux"), target_arch = "aarch64", target_arch = "arm"))] #[cfg(any(not(target_os = "linux"), target_arch = "aarch64", target_arch = "arm"))]
pub async fn get_sysinfo_temperature_data( pub async fn arm_and_non_linux_temperature_data(
sys: &sysinfo::System, temp_type: &TemperatureType, actually_get: bool, sys: &sysinfo::System, temp_type: &TemperatureType, actually_get: bool,
) -> crate::utils::error::Result<Option<Vec<TempHarvest>>> { ) -> crate::utils::error::Result<Option<Vec<TempHarvest>>> {
use sysinfo::{ComponentExt, SystemExt}; use sysinfo::{ComponentExt, SystemExt};
@ -61,7 +61,7 @@ pub async fn get_sysinfo_temperature_data(
} }
#[cfg(not(any(not(target_os = "linux"), target_arch = "aarch64", target_arch = "arm")))] #[cfg(not(any(not(target_os = "linux"), target_arch = "aarch64", target_arch = "arm")))]
pub async fn get_heim_temperature_data( pub async fn linux_temperature_data(
temp_type: &TemperatureType, actually_get: bool, temp_type: &TemperatureType, actually_get: bool,
) -> crate::utils::error::Result<Option<Vec<TempHarvest>>> { ) -> crate::utils::error::Result<Option<Vec<TempHarvest>>> {
use futures::StreamExt; use futures::StreamExt;

View File

@ -728,7 +728,6 @@ impl ProcessTableWidget for Painter {
.iter() .iter()
.map(|column| Row::Data(vec![column].into_iter())); .map(|column| Row::Data(vec![column].into_iter()));
// FIXME: [State] Shorten state to small form if it can't fit...?
let column_state = &mut proc_widget_state.columns.column_state; let column_state = &mut proc_widget_state.columns.column_state;
column_state.select(Some( column_state.select(Some(
proc_widget_state proc_widget_state