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, @@ -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 similarity index 100% rename from src/app/data_harvester.rs rename to src/data_collection.rs diff --git a/src/app/data_harvester/batteries.rs b/src/data_collection/batteries.rs similarity index 100% rename from src/app/data_harvester/batteries.rs rename to src/data_collection/batteries.rs diff --git a/src/app/data_harvester/batteries/battery.rs b/src/data_collection/batteries/battery.rs similarity index 100% rename from src/app/data_harvester/batteries/battery.rs rename to src/data_collection/batteries/battery.rs diff --git a/src/app/data_harvester/cpu.rs b/src/data_collection/cpu.rs similarity index 100% rename from src/app/data_harvester/cpu.rs rename to src/data_collection/cpu.rs diff --git a/src/app/data_harvester/cpu/sysinfo.rs b/src/data_collection/cpu/sysinfo.rs similarity index 94% rename from src/app/data_harvester/cpu/sysinfo.rs rename to 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 { let mut cpu_deque: VecDeque<_> = sys diff --git a/src/app/data_harvester/disks.rs b/src/data_collection/disks.rs similarity index 100% rename from src/app/data_harvester/disks.rs rename to src/data_collection/disks.rs diff --git a/src/app/data_harvester/disks/freebsd.rs b/src/data_collection/disks/freebsd.rs similarity index 93% rename from src/app/data_harvester/disks/freebsd.rs rename to 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 { #[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 similarity index 100% rename from src/app/data_harvester/disks/io_counters.rs rename to src/data_collection/disks/io_counters.rs diff --git a/src/app/data_harvester/disks/other.rs b/src/data_collection/disks/other.rs similarity index 97% rename from src/app/data_harvester/disks/other.rs rename to 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 similarity index 98% rename from src/app/data_harvester/disks/unix.rs rename to 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> { diff --git a/src/app/data_harvester/disks/unix/file_systems.rs b/src/data_collection/disks/unix/file_systems.rs similarity index 100% rename from src/app/data_harvester/disks/unix/file_systems.rs rename to 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 similarity index 96% rename from src/app/data_harvester/disks/unix/linux/counters.rs rename to 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> { #[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 similarity index 100% rename from src/app/data_harvester/disks/unix/linux/mod.rs rename to 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 similarity index 98% rename from src/app/data_harvester/disks/unix/linux/partition.rs rename to 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 similarity index 97% rename from src/app/data_harvester/disks/unix/macos/counters.rs rename to 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 { 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 similarity index 100% rename from src/app/data_harvester/disks/unix/macos/io_kit.rs rename to 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 similarity index 100% rename from src/app/data_harvester/disks/unix/macos/io_kit/bindings.rs rename to 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 similarity index 100% rename from src/app/data_harvester/disks/unix/macos/io_kit/io_disks.rs rename to 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 similarity index 100% rename from src/app/data_harvester/disks/unix/macos/io_kit/io_iterator.rs rename to 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 similarity index 100% rename from src/app/data_harvester/disks/unix/macos/io_kit/io_object.rs rename to 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 similarity index 100% rename from src/app/data_harvester/disks/unix/macos/mod.rs rename to 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 similarity index 100% rename from src/app/data_harvester/disks/unix/other/bindings.rs rename to 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 similarity index 100% rename from src/app/data_harvester/disks/unix/other/mod.rs rename to 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 similarity index 97% rename from src/app/data_harvester/disks/unix/other/partition.rs rename to 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 similarity index 100% rename from src/app/data_harvester/disks/unix/usage.rs rename to src/data_collection/disks/unix/usage.rs diff --git a/src/app/data_harvester/disks/windows.rs b/src/data_collection/disks/windows.rs similarity index 97% rename from src/app/data_harvester/disks/windows.rs rename to 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 similarity index 100% rename from src/app/data_harvester/disks/windows/bindings.rs rename to 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 similarity index 99% rename from src/app/data_harvester/disks/zfs_io_counters.rs rename to 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 similarity index 100% rename from src/app/data_harvester/memory.rs rename to src/data_collection/memory.rs diff --git a/src/app/data_harvester/memory/arc.rs b/src/data_collection/memory/arc.rs similarity index 100% rename from src/app/data_harvester/memory/arc.rs rename to src/data_collection/memory/arc.rs diff --git a/src/app/data_harvester/memory/sysinfo.rs b/src/data_collection/memory/sysinfo.rs similarity index 97% rename from src/app/data_harvester/memory/sysinfo.rs rename to src/data_collection/memory/sysinfo.rs index 119d44c5..58ec4e3a 100644 --- a/src/app/data_harvester/memory/sysinfo.rs +++ b/src/data_collection/memory/sysinfo.rs @@ -2,7 +2,7 @@ use sysinfo::{System, SystemExt}; -use crate::data_harvester::memory::MemHarvest; +use crate::data_collection::memory::MemHarvest; /// Returns RAM usage. pub(crate) fn get_ram_usage(sys: &System) -> Option { diff --git a/src/app/data_harvester/memory/windows.rs b/src/data_collection/memory/windows.rs similarity index 96% rename from src/app/data_harvester/memory/windows.rs rename to src/data_collection/memory/windows.rs index 5925a756..ba56df18 100644 --- a/src/app/data_harvester/memory/windows.rs +++ b/src/data_collection/memory/windows.rs @@ -2,7 +2,7 @@ use std::mem::{size_of, zeroed}; use windows::Win32::System::ProcessStatus::{GetPerformanceInfo, PERFORMANCE_INFORMATION}; -use crate::data_harvester::memory::MemHarvest; +use crate::data_collection::memory::MemHarvest; // TODO: Note this actually calculates the total *committed* usage. Rename and change label for accuracy! /// Get the committed memory usage. diff --git a/src/app/data_harvester/network.rs b/src/data_collection/network.rs similarity index 100% rename from src/app/data_harvester/network.rs rename to src/data_collection/network.rs diff --git a/src/app/data_harvester/network/sysinfo.rs b/src/data_collection/network/sysinfo.rs similarity index 97% rename from src/app/data_harvester/network/sysinfo.rs rename to src/data_collection/network/sysinfo.rs index 9c2aaade..a5b85d9a 100644 --- a/src/app/data_harvester/network/sysinfo.rs +++ b/src/data_collection/network/sysinfo.rs @@ -3,7 +3,7 @@ use std::time::Instant; use super::NetworkHarvest; -use crate::app::Filter; +use crate::app::filter::Filter; // TODO: Eventually make it so that this thing also takes individual usage into account, so we can show per-interface! pub fn get_network_data( diff --git a/src/app/data_harvester/nvidia.rs b/src/data_collection/nvidia.rs similarity index 97% rename from src/app/data_harvester/nvidia.rs rename to src/data_collection/nvidia.rs index 0acb7dcb..7d0b4be5 100644 --- a/src/app/data_harvester/nvidia.rs +++ b/src/data_collection/nvidia.rs @@ -5,11 +5,11 @@ use nvml_wrapper::enum_wrappers::device::TemperatureSensor; use nvml_wrapper::enums::device::UsedGpuMemory; use nvml_wrapper::{error::NvmlError, Nvml}; -use crate::app::Filter; +use crate::app::filter::Filter; use crate::app::layout_manager::UsedWidgets; -use crate::data_harvester::memory::MemHarvest; -use crate::data_harvester::temperature::{is_temp_filtered, TempHarvest, TemperatureType}; +use crate::data_collection::memory::MemHarvest; +use crate::data_collection::temperature::{is_temp_filtered, TempHarvest, TemperatureType}; pub static NVML_DATA: OnceLock> = OnceLock::new(); diff --git a/src/app/data_harvester/processes.rs b/src/data_collection/processes.rs similarity index 100% rename from src/app/data_harvester/processes.rs rename to src/data_collection/processes.rs diff --git a/src/app/data_harvester/processes/freebsd.rs b/src/data_collection/processes/freebsd.rs similarity index 95% rename from src/app/data_harvester/processes/freebsd.rs rename to src/data_collection/processes/freebsd.rs index 0d92d873..0da933f5 100644 --- a/src/app/data_harvester/processes/freebsd.rs +++ b/src/data_collection/processes/freebsd.rs @@ -6,7 +6,7 @@ use std::process::Command; use hashbrown::HashMap; use serde::{Deserialize, Deserializer}; -use crate::data_harvester::{deserialize_xo, processes::UnixProcessExt}; +use crate::data_collection::{deserialize_xo, processes::UnixProcessExt}; use crate::Pid; #[derive(Deserialize, Debug, Default)] diff --git a/src/app/data_harvester/processes/linux.rs b/src/data_collection/processes/linux.rs similarity index 99% rename from src/app/data_harvester/processes/linux.rs rename to src/data_collection/processes/linux.rs index 0a1ed539..0a1e9c64 100644 --- a/src/app/data_harvester/processes/linux.rs +++ b/src/data_collection/processes/linux.rs @@ -11,7 +11,7 @@ use hashbrown::HashSet; use sysinfo::ProcessStatus; use super::{ProcessHarvest, UserTable}; -use crate::app::data_harvester::DataCollector; +use crate::data_collection::DataCollector; use crate::utils::error::{self, BottomError}; use crate::Pid; diff --git a/src/app/data_harvester/processes/linux/process.rs b/src/data_collection/processes/linux/process.rs similarity index 100% rename from src/app/data_harvester/processes/linux/process.rs rename to src/data_collection/processes/linux/process.rs diff --git a/src/app/data_harvester/processes/macos.rs b/src/data_collection/processes/macos.rs similarity index 100% rename from src/app/data_harvester/processes/macos.rs rename to src/data_collection/processes/macos.rs diff --git a/src/app/data_harvester/processes/macos/sysctl_bindings.rs b/src/data_collection/processes/macos/sysctl_bindings.rs similarity index 100% rename from src/app/data_harvester/processes/macos/sysctl_bindings.rs rename to src/data_collection/processes/macos/sysctl_bindings.rs diff --git a/src/app/data_harvester/processes/unix.rs b/src/data_collection/processes/unix.rs similarity index 94% rename from src/app/data_harvester/processes/unix.rs rename to src/data_collection/processes/unix.rs index 1d42c2ca..2e79b578 100644 --- a/src/app/data_harvester/processes/unix.rs +++ b/src/data_collection/processes/unix.rs @@ -11,7 +11,7 @@ cfg_if! { use super::ProcessHarvest; - use crate::app::data_harvester::{DataCollector, processes::*}; + use crate::data_collection::{DataCollector, processes::*}; use crate::utils::error; pub fn sysinfo_process_data(collector: &mut DataCollector) -> error::Result> { diff --git a/src/app/data_harvester/processes/unix/process_ext.rs b/src/data_collection/processes/unix/process_ext.rs similarity index 98% rename from src/app/data_harvester/processes/unix/process_ext.rs rename to src/data_collection/processes/unix/process_ext.rs index 93ef3a94..c23c9ed3 100644 --- a/src/app/data_harvester/processes/unix/process_ext.rs +++ b/src/data_collection/processes/unix/process_ext.rs @@ -7,7 +7,7 @@ use hashbrown::HashMap; use sysinfo::{CpuExt, PidExt, ProcessExt, ProcessStatus, System, SystemExt}; use super::ProcessHarvest; -use crate::{data_harvester::processes::UserTable, utils::error, Pid}; +use crate::{data_collection::processes::UserTable, utils::error, Pid}; pub(crate) trait UnixProcessExt { fn sysinfo_process_data( diff --git a/src/app/data_harvester/processes/unix/user_table.rs b/src/data_collection/processes/unix/user_table.rs similarity index 100% rename from src/app/data_harvester/processes/unix/user_table.rs rename to src/data_collection/processes/unix/user_table.rs diff --git a/src/app/data_harvester/processes/windows.rs b/src/data_collection/processes/windows.rs similarity index 99% rename from src/app/data_harvester/processes/windows.rs rename to src/data_collection/processes/windows.rs index 11c58cf3..08309a55 100644 --- a/src/app/data_harvester/processes/windows.rs +++ b/src/data_collection/processes/windows.rs @@ -6,7 +6,7 @@ use sysinfo::{CpuExt, PidExt, ProcessExt, SystemExt, UserExt}; use super::ProcessHarvest; -use crate::data_harvester::DataCollector; +use crate::data_collection::DataCollector; pub fn sysinfo_process_data( collector: &mut DataCollector, diff --git a/src/app/data_harvester/temperature.rs b/src/data_collection/temperature.rs similarity index 95% rename from src/app/data_harvester/temperature.rs rename to src/data_collection/temperature.rs index 220190e6..db490027 100644 --- a/src/app/data_harvester/temperature.rs +++ b/src/data_collection/temperature.rs @@ -13,7 +13,7 @@ cfg_if::cfg_if! { } } -use crate::app::Filter; +use crate::app::filter::Filter; #[derive(Default, Debug, Clone)] pub struct TempHarvest { @@ -65,7 +65,7 @@ pub fn is_temp_filtered(filter: &Option, text: &str) -> bool { #[cfg(test)] mod test { - use crate::app::data_harvester::temperature::TemperatureType; + use crate::data_collection::temperature::TemperatureType; #[test] fn temp_conversions() { diff --git a/src/app/data_harvester/temperature/linux.rs b/src/data_collection/temperature/linux.rs similarity index 99% rename from src/app/data_harvester/temperature/linux.rs rename to src/data_collection/temperature/linux.rs index 7e089117..50b858d1 100644 --- a/src/app/data_harvester/temperature/linux.rs +++ b/src/data_collection/temperature/linux.rs @@ -9,7 +9,7 @@ use anyhow::Result; use hashbrown::{HashMap, HashSet}; use super::{is_temp_filtered, TempHarvest, TemperatureType}; -use crate::{app::Filter, utils::error::BottomError}; +use crate::{app::filter::Filter, utils::error::BottomError}; const EMPTY_NAME: &str = "Unknown"; diff --git a/src/app/data_harvester/temperature/sysinfo.rs b/src/data_collection/temperature/sysinfo.rs similarity index 98% rename from src/app/data_harvester/temperature/sysinfo.rs rename to src/data_collection/temperature/sysinfo.rs index 4e28efa7..9a2ea403 100644 --- a/src/app/data_harvester/temperature/sysinfo.rs +++ b/src/data_collection/temperature/sysinfo.rs @@ -3,7 +3,7 @@ use anyhow::Result; use super::{is_temp_filtered, TempHarvest, TemperatureType}; -use crate::app::Filter; +use crate::app::filter::Filter; pub fn get_temperature_data( sys: &sysinfo::System, temp_type: &TemperatureType, filter: &Option, diff --git a/src/data_conversion.rs b/src/data_conversion.rs index e1f5e08f..103e3a97 100644 --- a/src/data_conversion.rs +++ b/src/data_conversion.rs @@ -3,13 +3,9 @@ use kstring::KString; -use crate::app::data_harvester::memory::MemHarvest; -use crate::app::{ - data_farmer::DataCollection, - data_harvester::{cpu::CpuDataType, temperature::TemperatureType}, - AxisScaling, -}; +use crate::app::{data_farmer::DataCollection, AxisScaling}; use crate::components::tui_widget::time_chart::Point; +use crate::data_collection::{cpu::CpuDataType, memory::MemHarvest, temperature::TemperatureType}; use crate::utils::data_prefixes::*; use crate::utils::data_units::DataUnit; use crate::utils::gen_util::*; diff --git a/src/lib.rs b/src/lib.rs index b0944b7e..5614c888 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,7 +26,6 @@ use std::{ }; use app::{ - data_harvester, frozen_state::FrozenState, layout_manager::{UsedWidgets, WidgetDirection}, App, AppConfigFields, DataFilters, @@ -57,6 +56,7 @@ pub mod args; pub mod canvas; pub mod components; pub mod constants; +pub mod data_collection; pub mod data_conversion; pub mod options; pub mod widgets; @@ -76,7 +76,7 @@ pub enum BottomEvent { KeyInput(KeyEvent), MouseInput(MouseEvent), PasteEvent(String), - Update(Box), + Update(Box), Clean, Terminate, } @@ -485,7 +485,7 @@ pub fn create_collection_thread( let update_time = app_config_fields.update_rate; thread::spawn(move || { - let mut data_state = data_harvester::DataCollector::new(filters); + let mut data_state = data_collection::DataCollector::new(filters); data_state.set_data_collection(used_widget_set); data_state.set_temperature_type(temp_type); @@ -524,7 +524,7 @@ pub fn create_collection_thread( } let event = BottomEvent::Update(Box::from(data_state.data)); - data_state.data = data_harvester::Data::default(); + data_state.data = data_collection::Data::default(); if sender.send(event).is_err() { break; } diff --git a/src/options.rs b/src/options.rs index 08c96e34..92618400 100644 --- a/src/options.rs +++ b/src/options.rs @@ -19,6 +19,7 @@ use crate::{ app::{filter::Filter, layout_manager::*, *}, canvas::{canvas_styling::CanvasStyling, ColourScheme}, constants::*, + data_collection::temperature::TemperatureType, utils::{ data_units::DataUnit, error::{self, BottomError}, @@ -581,29 +582,27 @@ fn get_update_rate(matches: &ArgMatches, config: &Config) -> error::Result Ok(update_rate) } -fn get_temperature( - matches: &ArgMatches, config: &Config, -) -> error::Result { +fn get_temperature(matches: &ArgMatches, config: &Config) -> error::Result { if matches.get_flag("fahrenheit") { - return Ok(data_harvester::temperature::TemperatureType::Fahrenheit); + return Ok(TemperatureType::Fahrenheit); } else if matches.get_flag("kelvin") { - return Ok(data_harvester::temperature::TemperatureType::Kelvin); + return Ok(TemperatureType::Kelvin); } else if matches.get_flag("celsius") { - return Ok(data_harvester::temperature::TemperatureType::Celsius); + return Ok(TemperatureType::Celsius); } else if let Some(flags) = &config.flags { if let Some(temp_type) = &flags.temperature_type { // Give lowest priority to config. return match temp_type.as_str() { - "fahrenheit" | "f" => Ok(data_harvester::temperature::TemperatureType::Fahrenheit), - "kelvin" | "k" => Ok(data_harvester::temperature::TemperatureType::Kelvin), - "celsius" | "c" => Ok(data_harvester::temperature::TemperatureType::Celsius), + "fahrenheit" | "f" => Ok(TemperatureType::Fahrenheit), + "kelvin" | "k" => Ok(TemperatureType::Kelvin), + "celsius" | "c" => Ok(TemperatureType::Celsius), _ => Err(BottomError::ConfigError(format!( "\"{temp_type}\" is an invalid temperature type, use \"\"." ))), }; } } - Ok(data_harvester::temperature::TemperatureType::Celsius) + Ok(TemperatureType::Celsius) } /// Yes, this function gets whether to show average CPU (true) or not (false) diff --git a/src/widgets/cpu_graph.rs b/src/widgets/cpu_graph.rs index 3d3e6df1..7187b2fe 100644 --- a/src/widgets/cpu_graph.rs +++ b/src/widgets/cpu_graph.rs @@ -4,12 +4,13 @@ use concat_string::concat_string; use tui::{style::Style, text::Text, widgets::Row}; use crate::{ - app::{data_harvester::cpu::CpuDataType, AppConfigFields}, + app::AppConfigFields, canvas::{canvas_styling::CanvasStyling, Painter}, components::data_table::{ Column, ColumnHeader, DataTable, DataTableColumn, DataTableProps, DataTableStyling, DataToCell, }, + data_collection::cpu::CpuDataType, data_conversion::CpuWidgetData, options::CpuDefault, utils::gen_util::truncate_to_text, diff --git a/src/widgets/process_table.rs b/src/widgets/process_table.rs index 5aa03c9a..cf76d151 100644 --- a/src/widgets/process_table.rs +++ b/src/widgets/process_table.rs @@ -8,7 +8,6 @@ use serde::{de::Error, Deserialize}; use crate::{ app::{ data_farmer::{DataCollection, ProcessData}, - data_harvester::processes::ProcessHarvest, query::*, AppConfigFields, AppSearchState, }, @@ -17,6 +16,7 @@ use crate::{ Column, ColumnHeader, ColumnWidthBounds, DataTable, DataTableColumn, DataTableProps, DataTableStyling, SortColumn, SortDataTable, SortDataTableProps, SortOrder, SortsRow, }, + data_collection::processes::ProcessHarvest, Pid, }; diff --git a/src/widgets/process_table/proc_widget_data.rs b/src/widgets/process_table/proc_widget_data.rs index e234d8ec..c11a6d04 100644 --- a/src/widgets/process_table/proc_widget_data.rs +++ b/src/widgets/process_table/proc_widget_data.rs @@ -9,9 +9,9 @@ use tui::{text::Text, widgets::Row}; use super::proc_widget_column::ProcColumn; use crate::{ - app::data_harvester::processes::ProcessHarvest, canvas::Painter, components::data_table::{DataTableColumn, DataToCell}, + data_collection::processes::ProcessHarvest, data_conversion::{binary_byte_string, dec_bytes_per_second_string, dec_bytes_string}, utils::gen_util::truncate_to_text, Pid, diff --git a/src/widgets/temperature_table.rs b/src/widgets/temperature_table.rs index 3f570c0b..a9bed5ba 100644 --- a/src/widgets/temperature_table.rs +++ b/src/widgets/temperature_table.rs @@ -5,12 +5,13 @@ use kstring::KString; use tui::text::Text; use crate::{ - app::{data_harvester::temperature::TemperatureType, AppConfigFields}, + app::AppConfigFields, canvas::canvas_styling::CanvasStyling, components::data_table::{ ColumnHeader, DataTableColumn, DataTableProps, DataTableStyling, DataToCell, SortColumn, SortDataTable, SortDataTableProps, SortOrder, SortsRow, }, + data_collection::temperature::TemperatureType, utils::gen_util::{sort_partial_fn, truncate_to_text}, };