summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClement Tsang <34804052+ClementTsang@users.noreply.github.com>2023-12-28 04:00:58 +0000
committerGitHub <noreply@github.com>2023-12-27 23:00:58 -0500
commit22b40780ade874bed8682f0ffc31450458bd5659 (patch)
treec3c67626498aea1e14be0b47b9ef1fc637450cdd
parent28d2950d92f44f3b664fcaeede07e5ed4b30fd49 (diff)
refactor: pull data collection out of nested folder structure (#1364)
* refactor: pull data collection out of nested folder structure * fix sysinfo * comment
-rw-r--r--src/app.rs7
-rw-r--r--src/app/data_farmer.rs5
-rw-r--r--src/app/query.rs2
-rw-r--r--src/canvas.rs1
-rw-r--r--src/canvas/widgets/cpu_basic.rs3
-rw-r--r--src/data_collection.rs (renamed from src/app/data_harvester.rs)0
-rw-r--r--src/data_collection/batteries.rs (renamed from src/app/data_harvester/batteries.rs)0
-rw-r--r--src/data_collection/batteries/battery.rs (renamed from src/app/data_harvester/batteries/battery.rs)0
-rw-r--r--src/data_collection/cpu.rs (renamed from src/app/data_harvester/cpu.rs)0
-rw-r--r--src/data_collection/cpu/sysinfo.rs (renamed from src/app/data_harvester/cpu/sysinfo.rs)2
-rw-r--r--src/data_collection/disks.rs (renamed from src/app/data_harvester/disks.rs)0
-rw-r--r--src/data_collection/disks/freebsd.rs (renamed from src/app/data_harvester/disks/freebsd.rs)6
-rw-r--r--src/data_collection/disks/io_counters.rs (renamed from src/app/data_harvester/disks/io_counters.rs)0
-rw-r--r--src/data_collection/disks/other.rs (renamed from src/app/data_harvester/disks/other.rs)2
-rw-r--r--src/data_collection/disks/unix.rs (renamed from src/app/data_harvester/disks/unix.rs)2
-rw-r--r--src/data_collection/disks/unix/file_systems.rs (renamed from src/app/data_harvester/disks/unix/file_systems.rs)0
-rw-r--r--src/data_collection/disks/unix/linux/counters.rs (renamed from src/app/data_harvester/disks/unix/linux/counters.rs)4
-rw-r--r--src/data_collection/disks/unix/linux/mod.rs (renamed from src/app/data_harvester/disks/unix/linux/mod.rs)0
-rw-r--r--src/data_collection/disks/unix/linux/partition.rs (renamed from src/app/data_harvester/disks/unix/linux/partition.rs)2
-rw-r--r--src/data_collection/disks/unix/macos/counters.rs (renamed from src/app/data_harvester/disks/unix/macos/counters.rs)2
-rw-r--r--src/data_collection/disks/unix/macos/io_kit.rs (renamed from src/app/data_harvester/disks/unix/macos/io_kit.rs)0
-rw-r--r--src/data_collection/disks/unix/macos/io_kit/bindings.rs (renamed from src/app/data_harvester/disks/unix/macos/io_kit/bindings.rs)0
-rw-r--r--src/data_collection/disks/unix/macos/io_kit/io_disks.rs (renamed from src/app/data_harvester/disks/unix/macos/io_kit/io_disks.rs)0
-rw-r--r--src/data_collection/disks/unix/macos/io_kit/io_iterator.rs (renamed from src/app/data_harvester/disks/unix/macos/io_kit/io_iterator.rs)0
-rw-r--r--src/data_collection/disks/unix/macos/io_kit/io_object.rs (renamed from src/app/data_harvester/disks/unix/macos/io_kit/io_object.rs)0
-rw-r--r--src/data_collection/disks/unix/macos/mod.rs (renamed from src/app/data_harvester/disks/unix/macos/mod.rs)0
-rw-r--r--src/data_collection/disks/unix/other/bindings.rs (renamed from src/app/data_harvester/disks/unix/other/bindings.rs)0
-rw-r--r--src/data_collection/disks/unix/other/mod.rs (renamed from src/app/data_harvester/disks/unix/other/mod.rs)0
-rw-r--r--src/data_collection/disks/unix/other/partition.rs (renamed from src/app/data_harvester/disks/unix/other/partition.rs)2
-rw-r--r--src/data_collection/disks/unix/usage.rs (renamed from src/app/data_harvester/disks/unix/usage.rs)0
-rw-r--r--src/data_collection/disks/windows.rs (renamed from src/app/data_harvester/disks/windows.rs)2
-rw-r--r--src/data_collection/disks/windows/bindings.rs (renamed from src/app/data_harvester/disks/windows/bindings.rs)0
-rw-r--r--src/data_collection/disks/zfs_io_counters.rs (renamed from src/app/data_harvester/disks/zfs_io_counters.rs)2
-rw-r--r--src/data_collection/memory.rs (renamed from src/app/data_harvester/memory.rs)0
-rw-r--r--src/data_collection/memory/arc.rs (renamed from src/app/data_harvester/memory/arc.rs)0
-rw-r--r--src/data_collection/memory/sysinfo.rs (renamed from src/app/data_harvester/memory/sysinfo.rs)2
-rw-r--r--src/data_collection/memory/windows.rs (renamed from src/app/data_harvester/memory/windows.rs)2
-rw-r--r--src/data_collection/network.rs (renamed from src/app/data_harvester/network.rs)0
-rw-r--r--src/data_collection/network/sysinfo.rs (renamed from src/app/data_harvester/network/sysinfo.rs)2
-rw-r--r--src/data_collection/nvidia.rs (renamed from src/app/data_harvester/nvidia.rs)6
-rw-r--r--src/data_collection/processes.rs (renamed from src/app/data_harvester/processes.rs)0
-rw-r--r--src/data_collection/processes/freebsd.rs (renamed from src/app/data_harvester/processes/freebsd.rs)2
-rw-r--r--src/data_collection/processes/linux.rs (renamed from src/app/data_harvester/processes/linux.rs)2
-rw-r--r--src/data_collection/processes/linux/process.rs (renamed from src/app/data_harvester/processes/linux/process.rs)0
-rw-r--r--src/data_collection/processes/macos.rs (renamed from src/app/data_harvester/processes/macos.rs)0
-rw-r--r--src/data_collection/processes/macos/sysctl_bindings.rs (renamed from src/app/data_harvester/processes/macos/sysctl_bindings.rs)0
-rw-r--r--src/data_collection/processes/unix.rs (renamed from src/app/data_harvester/processes/unix.rs)2
-rw-r--r--src/data_collection/processes/unix/process_ext.rs (renamed from src/app/data_harvester/processes/unix/process_ext.rs)2
-rw-r--r--src/data_collection/processes/unix/user_table.rs (renamed from src/app/data_harvester/processes/unix/user_table.rs)0
-rw-r--r--src/data_collection/processes/windows.rs (renamed from src/app/data_harvester/processes/windows.rs)2
-rw-r--r--src/data_collection/temperature.rs (renamed from src/app/data_harvester/temperature.rs)4
-rw-r--r--src/data_collection/temperature/linux.rs (renamed from src/app/data_harvester/temperature/linux.rs)2
-rw-r--r--src/data_collection/temperature/sysinfo.rs (renamed from src/app/data_harvester/temperature/sysinfo.rs)2
-rw-r--r--src/data_conversion.rs8
-rw-r--r--src/lib.rs8
-rw-r--r--src/options.rs19
-rw-r--r--src/widgets/cpu_graph.rs3
-rw-r--r--src/widgets/process_table.rs2
-rw-r--r--src/widgets/process_table/proc_widget_data.rs2
-rw-r--r--src/widgets/temperature_table.rs3
60 files changed, 59 insertions, 60 deletions
diff --git a/src/app.rs b/src/app.rs
index 005a743b..ddbc05af 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -5,7 +5,6 @@ use std::{
use concat_string::concat_string;
use data_farmer::*;
-use data_harvester::temperature;
use filter::*;
use hashbrown::HashMap;
use layout_manager::*;
@@ -14,6 +13,7 @@ use unicode_segmentation::{GraphemeCursor, UnicodeSegmentation};
use crate::{
constants,
+ data_collection::temperature,
data_conversion::ConvertedData,
utils::error::{BottomError, Result},
Pid,
@@ -24,7 +24,6 @@ use crate::{
};
pub mod data_farmer;
-pub mod data_harvester;
pub mod filter;
pub mod frozen_state;
pub mod layout_manager;
@@ -117,7 +116,7 @@ pub struct App {
pub is_determining_widget_boundary: bool,
pub basic_mode_use_percent: bool,
#[cfg(target_family = "unix")]
- pub user_table: data_harvester::processes::UserTable,
+ pub user_table: crate::data_collection::processes::UserTable,
pub states: AppWidgetStates,
pub app_config_fields: AppConfigFields,
pub widget_map: HashMap<u64, BottomWidget>,
@@ -148,7 +147,7 @@ impl App {
is_determining_widget_boundary: false,
basic_mode_use_percent: false,
#[cfg(target_family = "unix")]
- user_table: data_harvester::processes::UserTable::default(),
+ user_table: crate::data_collection::processes::UserTable::default(),
states,
app_config_fields,
widget_map,
diff --git a/src/app/data_farmer.rs b/src/app/data_farmer.rs
index 669e4630..4a2e09fe 100644
--- a/src/app/data_farmer.rs
+++ b/src/app/data_farmer.rs
@@ -13,14 +13,15 @@
//! memory usage and higher CPU usage - you will be trying to process more and
//! more points as this is used!
+use crate::data_collection::processes::ProcessHarvest;
use std::{collections::BTreeMap, time::Instant, vec::Vec};
use hashbrown::HashMap;
#[cfg(feature = "battery")]
-use crate::data_harvester::batteries;
+use crate::data_collection::batteries;
use crate::{
- data_harvester::{cpu, disks, memory, network, processes::ProcessHarvest, temperature, Data},
+ data_collection::{cpu, disks, memory, network, temperature, Data},
utils::data_prefixes::*,
utils::gen_util::get_decimal_bytes,
Pid,
diff --git a/src/app/query.rs b/src/app/query.rs
index 7cbabafa..6f1a2858 100644
--- a/src/app/query.rs
+++ b/src/app/query.rs
@@ -5,7 +5,7 @@ use std::{borrow::Cow, collections::VecDeque};
use humantime::parse_duration;
use regex::Regex;
-use super::data_harvester::processes::ProcessHarvest;
+use crate::data_collection::processes::ProcessHarvest;
use crate::multi_eq_ignore_ascii_case;
use crate::utils::data_prefixes::*;
use crate::utils::error::{
diff --git a/src/canvas.rs b/src/canvas.rs
index 44a74cea..ef5c9ace 100644
--- a/src/canvas.rs
+++ b/src/canvas.rs
@@ -231,6 +231,7 @@ impl Painter {
terminal.draw(|f| {
let (terminal_size, frozen_draw_loc) = if app_state.frozen_state.is_frozen() {
+ // TODO: Remove built-in cache?
let split_loc = Layout::default()
.constraints([Constraint::Min(0), Constraint::Length(1)])
.split(f.size());
diff --git a/src/canvas/widgets/cpu_basic.rs b/src/canvas/widgets/cpu_basic.rs
index da502d69..6c87804a 100644
--- a/src/canvas/widgets/cpu_basic.rs
+++ b/src/canvas/widgets/cpu_basic.rs
@@ -7,10 +7,11 @@ use tui::{
};
use crate::{
- app::{data_harvester::cpu::CpuDataType, App},
+ app::App,
canvas::Painter,
components::tui_widget::pipe_gauge::{LabelLimit, PipeGauge},
constants::*,
+ data_collection::cpu::CpuDataType,
data_conversion::CpuWidgetData,
};
diff --git a/src/app/data_harvester.rs b/src/data_collection.rs
index d140e29e..d140e29e 100644
--- a/src/app/data_harvester.rs
+++ b/src/data_collection.rs
diff --git a/src/app/data_harvester/batteries.rs b/src/data_collection/batteries.rs
index 8c0e4a92..8c0e4a92 100644
--- a/src/app/data_harvester/batteries.rs
+++ b/src/data_collection/batteries.rs
diff --git a/src/app/data_harvester/batteries/battery.rs b/src/data_collection/batteries/battery.rs
index ec95ada2..ec95ada2 100644
--- a/src/app/data_harvester/batteries/battery.rs
+++ b/src/data_collection/batteries/battery.rs
diff --git a/src/app/data_harvester/cpu.rs b/src/data_collection/cpu.rs
index 843df161..843df161 100644
--- a/src/app/data_harvester/cpu.rs
+++ b/src/data_collection/cpu.rs
diff --git a/src/app/data_harvester/cpu/sysinfo.rs b/src/data_collection/cpu/sysinfo.rs
index 0d79e347..9970eadf 100644
--- a/src/app/data_harvester/cpu/sysinfo.rs
+++ b/src/data_collection/cpu/sysinfo.rs
@@ -6,7 +6,7 @@ use std::collections::VecDeque;
use sysinfo::{CpuExt, LoadAvg, System, SystemExt};
use super::{CpuData, CpuDataType, CpuHarvest};
-use crate::app::data_harvester::cpu::LoadAvgHarvest;
+use crate::data_collection::cpu::LoadAvgHarvest;
pub fn get_cpu_data_list(sys: &System, show_average_cpu: bool) -> crate::error::Result<CpuHarvest> {
let mut cpu_deque: VecDeque<_> = sys
diff --git a/src/app/data_harvester/disks.rs b/src/data_collection/disks.rs
index c4a66eff..c4a66eff 100644
--- a/src/app/data_harvester/disks.rs
+++ b/src/data_collection/disks.rs
diff --git a/src/app/data_harvester/disks/freebsd.rs b/src/data_collection/disks/freebsd.rs
index 4c392ebc..bb44e1ad 100644
--- a/src/app/data_harvester/disks/freebsd.rs
+++ b/src/data_collection/disks/freebsd.rs
@@ -7,8 +7,8 @@ use serde::Deserialize;
use super::{keep_disk_entry, DiskHarvest, IoHarvest};
use crate::{
- app::data_harvester::DataCollector, data_harvester::deserialize_xo,
- data_harvester::disks::IoData, utils::error,
+ data_collection::deserialize_xo, data_collection::disks::IoData,
+ data_collection::DataCollector, utils::error,
};
use hashbrown::HashMap;
@@ -42,7 +42,7 @@ pub fn get_io_usage() -> error::Result<IoHarvest> {
#[cfg(feature = "zfs")]
{
- use crate::app::data_harvester::disks::zfs_io_counters;
+ use crate::data_collection::disks::zfs_io_counters;
if let Ok(zfs_io) = zfs_io_counters::zfs_io_stats() {
for io in zfs_io.into_iter() {
let mount_point = io.device_name().to_string_lossy();
diff --git a/src/app/data_harvester/disks/io_counters.rs b/src/data_collection/disks/io_counters.rs
index 2b07fa5d..2b07fa5d 100644
--- a/src/app/data_harvester/disks/io_counters.rs
+++ b/src/data_collection/disks/io_counters.rs
diff --git a/src/app/data_harvester/disks/other.rs b/src/data_collection/disks/other.rs
index 6dac7e93..3e35a6b7 100644
--- a/src/app/data_harvester/disks/other.rs
+++ b/src/data_collection/disks/other.rs
@@ -2,7 +2,7 @@
use sysinfo::{DiskExt, SystemExt};
-use crate::app::data_harvester::DataCollector;
+use crate::data_collection::DataCollector;
use super::{keep_disk_entry, DiskHarvest};
diff --git a/src/app/data_harvester/disks/unix.rs b/src/data_collection/disks/unix.rs
index e8ebaeeb..e41b0458 100644
--- a/src/app/data_harvester/disks/unix.rs
+++ b/src/data_collection/disks/unix.rs
@@ -25,7 +25,7 @@ cfg_if::cfg_if! {
}
use super::{keep_disk_entry, DiskHarvest};
-use crate::app::data_harvester::DataCollector;
+use crate::data_collection::DataCollector;
/// Returns the disk usage of the mounted (and for now, physical) disks.
pub fn get_disk_usage(collector: &DataCollector) -> anyhow::Result<Vec<DiskHarvest>> {
diff --git a/src/app/data_harvester/disks/unix/file_systems.rs b/src/data_collection/disks/unix/file_systems.rs
index 15bdc3ac..15bdc3ac 100644
--- a/src/app/data_harvester/disks/unix/file_systems.rs
+++ b/src/data_collection/disks/unix/file_systems.rs
diff --git a/src/app/data_harvester/disks/unix/linux/counters.rs b/src/data_collection/disks/unix/linux/counters.rs
index c51aecf7..bc2cb076 100644
--- a/src/app/data_harvester/disks/unix/linux/counters.rs
+++ b/src/data_collection/disks/unix/linux/counters.rs
@@ -7,7 +7,7 @@ use std::{
str::FromStr,
};
-use crate::app::data_harvester::disks::IoCounters;
+use crate::data_collection::disks::IoCounters;
/// Copied from the `psutil` sources:
///
@@ -85,7 +85,7 @@ pub fn io_stats() -> anyhow::Result<Vec<IoCounters>> {
#[cfg(feature = "zfs")]
{
- use crate::app::data_harvester::disks::zfs_io_counters;
+ use crate::data_collection::disks::zfs_io_counters;
if let Ok(mut zfs_io) = zfs_io_counters::zfs_io_stats() {
results.append(&mut zfs_io);
}
diff --git a/src/app/data_harvester/disks/unix/linux/mod.rs b/src/data_collection/disks/unix/linux/mod.rs
index 40a83267..40a83267 100644
--- a/src/app/data_harvester/disks/unix/linux/mod.rs
+++ b/src/data_collection/disks/unix/linux/mod.rs
diff --git a/src/app/data_harvester/disks/unix/linux/partition.rs b/src/data_collection/disks/unix/linux/partition.rs
index 6f81965a..488ad8d9 100644
--- a/src/app/data_harvester/disks/unix/linux/partition.rs
+++ b/src/data_collection/disks/unix/linux/partition.rs
@@ -12,7 +12,7 @@ use std::{
use anyhow::bail;
-use crate::app::data_harvester::disks::unix::{FileSystem, Usage};
+use crate::data_collection::disks::unix::{FileSystem, Usage};
/// Representation of partition details. Based on [`heim`](https://github.com/heim-rs/heim/tree/master).
pub(crate) struct Partition {
diff --git a/src/app/data_harvester/disks/unix/macos/counters.rs b/src/data_collection/disks/unix/macos/counters.rs
index 731e0092..1f03b297 100644
--- a/src/app/data_harvester/disks/unix/macos/counters.rs
+++ b/src/data_collection/disks/unix/macos/counters.rs
@@ -1,7 +1,7 @@
//! Based on [heim's implementation](https://github.com/heim-rs/heim/blob/master/heim-disk/src/sys/macos/counters.rs).
use super::io_kit::{self, get_dict, get_disks, get_i64, get_string};
-use crate::app::data_harvester::disks::IoCounters;
+use crate::data_collection::disks::IoCounters;
fn get_device_io(device: io_kit::IoObject) -> anyhow::Result<IoCounters> {
let parent = device.service_parent()?;
diff --git a/src/app/data_harvester/disks/unix/macos/io_kit.rs b/src/data_collection/disks/unix/macos/io_kit.rs
index 42193fbd..42193fbd 100644
--- a/src/app/data_harvester/disks/unix/macos/io_kit.rs
+++ b/src/data_collection/disks/unix/macos/io_kit.rs
diff --git a/src/app/data_harvester/disks/unix/macos/io_kit/bindings.rs b/src/data_collection/disks/unix/macos/io_kit/bindings.rs
index decc8a77..decc8a77 100644
--- a/src/app/data_harvester/disks/unix/macos/io_kit/bindings.rs
+++ b/src/data_collection/disks/unix/macos/io_kit/bindings.rs
diff --git a/src/app/data_harvester/disks/unix/macos/io_kit/io_disks.rs b/src/data_collection/disks/unix/macos/io_kit/io_disks.rs
index 9552b0b7..9552b0b7 100644
--- a/src/app/data_harvester/disks/unix/macos/io_kit/io_disks.rs
+++ b/src/data_collection/disks/unix/macos/io_kit/io_disks.rs
diff --git a/src/app/data_harvester/disks/unix/macos/io_kit/io_iterator.rs b/src/data_collection/disks/unix/macos/io_kit/io_iterator.rs
index 1f440466..1f440466 100644
--- a/src/app/data_harvester/disks/unix/macos/io_kit/io_iterator.rs
+++ b/src/data_collection/disks/unix/macos/io_kit/io_iterator.rs
diff --git a/src/app/data_harvester/disks/unix/macos/io_kit/io_object.rs b/src/data_collection/disks/unix/macos/io_kit/io_object.rs
index 0d567a86..0d567a86 100644
--- a/src/app/data_harvester/disks/unix/macos/io_kit/io_object.rs
+++ b/src/data_collection/disks/unix/macos/io_kit/io_object.rs
diff --git a/src/app/data_harvester/disks/unix/macos/mod.rs b/src/data_collection/disks/unix/macos/mod.rs
index 97d7e154..97d7e154 100644
--- a/src/app/data_harvester/disks/unix/macos/mod.rs
+++ b/src/data_collection/disks/unix/macos/mod.rs
diff --git a/src/app/data_harvester/disks/unix/other/bindings.rs b/src/data_collection/disks/unix/other/bindings.rs
index 0dd4b4fb..0dd4b4fb 100644
--- a/src/app/data_harvester/disks/unix/other/bindings.rs
+++ b/src/data_collection/disks/unix/other/bindings.rs
diff --git a/src/app/data_harvester/disks/unix/other/mod.rs b/src/data_collection/disks/unix/other/mod.rs
index 645d7c3f..645d7c3f 100644
--- a/src/app/data_harvester/disks/unix/other/mod.rs
+++ b/src/data_collection/disks/unix/other/mod.rs
diff --git a/src/app/data_harvester/disks/unix/other/partition.rs b/src/data_collection/disks/unix/other/partition.rs
index 341c5126..1e64a70d 100644
--- a/src/app/data_harvester/disks/unix/other/partition.rs
+++ b/src/data_collection/disks/unix/other/partition.rs
@@ -8,7 +8,7 @@ use std::{
use anyhow::bail;
use super::bindings;
-use crate::app::data_harvester::disks::unix::{FileSystem, Usage};
+use crate::data_collection::disks::unix::{FileSystem, Usage};
pub(crate) struct Partition {
device: String,
diff --git a/src/app/data_harvester/disks/unix/usage.rs b/src/data_collection/disks/unix/usage.rs
index d9e75323..d9e75323 100644
--- a/src/app/data_harvester/disks/unix/usage.rs
+++ b/src/data_collection/disks/unix/usage.rs
diff --git a/src/app/data_harvester/disks/windows.rs b/src/data_collection/disks/windows.rs
index 3bf872de..ae7bb025 100644
--- a/src/app/data_harvester/disks/windows.rs
+++ b/src/data_collection/disks/windows.rs
@@ -5,7 +5,7 @@ use sysinfo::{DiskExt, SystemExt};
use super::{keep_disk_entry, DiskHarvest};
-use crate::app::data_harvester::{disks::IoCounters, DataCollector};
+use crate::data_collection::{disks::IoCounters, DataCollector};
mod bindings;
use bindings::*;
diff --git a/src/app/data_harvester/disks/windows/bindings.rs b/src/data_collection/disks/windows/bindings.rs
index c5436145..c5436145 100644
--- a/src/app/data_harvester/disks/windows/bindings.rs
+++ b/src/data_collection/disks/windows/bindings.rs
diff --git a/src/app/data_harvester/disks/zfs_io_counters.rs b/src/data_collection/disks/zfs_io_counters.rs
index a4f30397..a577915a 100644
--- a/src/app/data_harvester/disks/zfs_io_counters.rs
+++ b/src/data_collection/disks/zfs_io_counters.rs
@@ -1,4 +1,4 @@
-use crate::app::data_harvester::disks::IoCounters;
+use crate::data_collection::disks::IoCounters;
/// Returns zpool I/O stats. Pulls data from `sysctl kstat.zfs.{POOL}.dataset.{objset-*}`
#[cfg(target_os = "freebsd")]
diff --git a/src/app/data_harvester/memory.rs b/src/data_collection/memory.rs
index dee65d8d..dee65d8d 100644
--- a/src/app/data_harvester/memory.rs
+++ b/src/data_collection/memory.rs
diff --git a/src/app/data_harvester/memory/arc.rs b/src/data_collection/memory/arc.rs
index b1eaae31..b1eaae31 100644
--- a/