summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorClement Tsang <34804052+ClementTsang@users.noreply.github.com>2022-11-10 01:22:19 -0500
committerGitHub <noreply@github.com>2022-11-10 01:22:19 -0500
commit99fc5fc2c85b714c81ec6a7fca2615853e120caa (patch)
treef87e929adf6922872b6a1de2acfb62820052fc7f /src
parentf5ec9191f270ffb4fc36e34836e931d3ef55a162 (diff)
refactor: run cargo +nightly fmt with group_imports (#885)
* refactor: add some disabled unstable fmt options * run cargo +nightly fmt with group_imports * separate out the cfg-specific imports for clarity
Diffstat (limited to 'src')
-rw-r--r--src/app.rs11
-rw-r--r--src/app/data_farmer.rs8
-rw-r--r--src/app/data_harvester.rs11
-rw-r--r--src/app/data_harvester/cpu/heim.rs7
-rw-r--r--src/app/data_harvester/cpu/heim/linux.rs3
-rw-r--r--src/app/data_harvester/disks/freebsd.rs3
-rw-r--r--src/app/data_harvester/memory/general/sysinfo.rs3
-rw-r--r--src/app/data_harvester/network/heim.rs3
-rw-r--r--src/app/data_harvester/network/sysinfo.rs3
-rw-r--r--src/app/data_harvester/processes/freebsd.rs4
-rw-r--r--src/app/data_harvester/processes/linux.rs13
-rw-r--r--src/app/data_harvester/processes/macos.rs2
-rw-r--r--src/app/data_harvester/processes/macos/sysctl_bindings.rs3
-rw-r--r--src/app/data_harvester/processes/macos_freebsd.rs2
-rw-r--r--src/app/data_harvester/processes/windows.rs3
-rw-r--r--src/app/data_harvester/temperature/linux.rs6
-rw-r--r--src/app/data_harvester/temperature/nvidia.rs6
-rw-r--r--src/app/data_harvester/temperature/sysinfo.rs3
-rw-r--r--src/app/layout_manager.rs3
-rw-r--r--src/app/query.rs8
-rw-r--r--src/app/states.rs9
-rw-r--r--src/app/widgets/cpu_graph.rs1
-rw-r--r--src/app/widgets/process_table.rs6
-rw-r--r--src/app/widgets/process_table/proc_widget_column.rs7
-rw-r--r--src/app/widgets/process_table/proc_widget_data.rs3
-rw-r--r--src/bin/main.rs15
-rw-r--r--src/canvas.rs5
-rw-r--r--src/canvas/canvas_colours.rs10
-rw-r--r--src/canvas/canvas_colours/colour_utils.rs2
-rw-r--r--src/canvas/dialogs/dd_dialog.rs1
-rw-r--r--src/canvas/dialogs/help_dialog.rs6
-rw-r--r--src/canvas/drawing_utils.rs7
-rw-r--r--src/canvas/widgets/basic_table_arrows.rs10
-rw-r--r--src/canvas/widgets/battery_display.rs12
-rw-r--r--src/canvas/widgets/cpu_basic.rs14
-rw-r--r--src/canvas/widgets/cpu_graph.rs15
-rw-r--r--src/canvas/widgets/mem_basic.rs8
-rw-r--r--src/canvas/widgets/mem_graph.rs12
-rw-r--r--src/canvas/widgets/network_basic.rs4
-rw-r--r--src/canvas/widgets/network_graph.rs16
-rw-r--r--src/canvas/widgets/process_table.rs15
-rw-r--r--src/components/data_table/data_type.rs3
-rw-r--r--src/components/data_table/draw.rs9
-rw-r--r--src/components/data_table/sortable.rs3
-rw-r--r--src/components/time_graph.rs6
-rw-r--r--src/components/tui_widget/time_chart.rs1
-rw-r--r--src/constants.rs3
-rw-r--r--src/data_conversion.rs4
-rw-r--r--src/lib.rs18
-rw-r--r--src/options.rs11
-rw-r--r--src/options/layout_options.rs3
-rw-r--r--src/utils/error.rs1
52 files changed, 169 insertions, 176 deletions
diff --git a/src/app.rs b/src/app.rs
index ea34f259..3669bfa9 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -5,16 +5,15 @@ use std::{
};
use concat_string::concat_string;
-use unicode_segmentation::{GraphemeCursor, UnicodeSegmentation};
-use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};
-
-use typed_builder::*;
-
use data_farmer::*;
use data_harvester::temperature;
use layout_manager::*;
pub use states::*;
+use typed_builder::*;
+use unicode_segmentation::{GraphemeCursor, UnicodeSegmentation};
+use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};
+use self::widgets::{ProcWidget, ProcWidgetMode};
use crate::{
constants,
data_conversion::ConvertedData,
@@ -23,8 +22,6 @@ use crate::{
Pid,
};
-use self::widgets::{ProcWidget, ProcWidgetMode};
-
pub mod data_farmer;
pub mod data_harvester;
pub mod frozen_state;
diff --git a/src/app/data_farmer.rs b/src/app/data_farmer.rs
index f0427c5d..2749c9bc 100644
--- a/src/app/data_farmer.rs
+++ b/src/app/data_farmer.rs
@@ -13,22 +13,20 @@
//! memory usage and higher CPU usage - you will be trying to process more and
//! more points as this is used!
-use once_cell::sync::Lazy;
+use std::{time::Instant, vec::Vec};
use fxhash::FxHashMap;
use itertools::Itertools;
-
-use std::{time::Instant, vec::Vec};
+use once_cell::sync::Lazy;
+use regex::Regex;
#[cfg(feature = "battery")]
use crate::data_harvester::batteries;
-
use crate::{
data_harvester::{cpu, disks, memory, network, processes::ProcessHarvest, temperature, Data},
utils::gen_util::{get_decimal_bytes, GIGA_LIMIT},
Pid,
};
-use regex::Regex;
pub type TimeOffset = f64;
pub type Value = f64;
diff --git a/src/app/data_harvester.rs b/src/app/data_harvester.rs
index f289f41f..f15c0fcb 100644
--- a/src/app/data_harvester.rs
+++ b/src/app/data_harvester.rs
@@ -2,20 +2,19 @@
use std::time::Instant;
+use futures::join;
+
#[cfg(target_os = "linux")]
use fxhash::FxHashMap;
-#[cfg(not(target_os = "linux"))]
-use sysinfo::{System, SystemExt};
-
#[cfg(feature = "battery")]
use starship_battery::{Battery, Manager};
-use crate::app::layout_manager::UsedWidgets;
-
-use futures::join;
+#[cfg(not(target_os = "linux"))]
+use sysinfo::{System, SystemExt};
use super::DataFilters;
+use crate::app::layout_manager::UsedWidgets;
#[cfg(feature = "nvidia")]
pub mod nvidia;
diff --git a/src/app/data_harvester/cpu/heim.rs b/src/app/data_harvester/cpu/heim.rs
index de4fd033..f3aa92aa 100644
--- a/src/app/data_harvester/cpu/heim.rs
+++ b/src/app/data_harvester/cpu/heim.rs
@@ -18,14 +18,15 @@ cfg_if::cfg_if! {
}
}
+use std::collections::VecDeque;
+
+use futures::StreamExt;
+
use crate::{
components::tui_widget::time_chart::Point,
data_harvester::cpu::{CpuData, CpuDataType, CpuHarvest, PastCpuTotal, PastCpuWork},
};
-use futures::StreamExt;
-use std::collections::VecDeque;
-
pub async fn get_cpu_data_list(
show_average_cpu: bool, previous_cpu_times: &mut Vec<(PastCpuWork, PastCpuTotal)>,
previous_average_cpu_time: &mut Option<(PastCpuWork, PastCpuTotal)>,
diff --git a/src/app/data_harvester/cpu/heim/linux.rs b/src/app/data_harvester/cpu/heim/linux.rs
index f7bf3ead..f1b040c4 100644
--- a/src/app/data_harvester/cpu/heim/linux.rs
+++ b/src/app/data_harvester/cpu/heim/linux.rs
@@ -1,8 +1,9 @@
//! Linux-specific functions regarding CPU usage.
-use crate::components::tui_widget::time_chart::Point;
use heim::cpu::os::linux::CpuTimeExt;
+use crate::components::tui_widget::time_chart::Point;
+
pub fn convert_cpu_times(cpu_time: &heim::cpu::CpuTime) -> Point {
let working_time: f64 = (cpu_time.user()
+ cpu_time.nice()
diff --git a/src/app/data_harvester/disks/freebsd.rs b/src/app/data_harvester/disks/freebsd.rs
index d14dd793..d657931b 100644
--- a/src/app/data_harvester/disks/freebsd.rs
+++ b/src/app/data_harvester/disks/freebsd.rs
@@ -1,8 +1,9 @@
//! Disk stats for FreeBSD.
-use serde::Deserialize;
use std::io;
+use serde::Deserialize;
+
use super::{DiskHarvest, IoHarvest};
use crate::app::Filter;
use crate::data_harvester::deserialize_xo;
diff --git a/src/app/data_harvester/memory/general/sysinfo.rs b/src/app/data_harvester/memory/general/sysinfo.rs
index 93130e96..ea0f9077 100644
--- a/src/app/data_harvester/memory/general/sysinfo.rs
+++ b/src/app/data_harvester/memory/general/sysinfo.rs
@@ -1,8 +1,9 @@
//! Data collection for memory via sysinfo.
-use crate::data_harvester::memory::{MemCollect, MemHarvest};
use sysinfo::{System, SystemExt};
+use crate::data_harvester::memory::{MemCollect, MemHarvest};
+
pub async fn get_mem_data(sys: &System, actually_get: bool, _get_gpu: bool) -> MemCollect {
if !actually_get {
MemCollect {
diff --git a/src/app/data_harvester/network/heim.rs b/src/app/data_harvester/network/heim.rs
index b7980ddb..28144a55 100644
--- a/src/app/data_harvester/network/heim.rs
+++ b/src/app/data_harvester/network/heim.rs
@@ -1,8 +1,9 @@
//! Gets network data via heim.
-use super::NetworkHarvest;
use std::time::Instant;
+use super::NetworkHarvest;
+
// TODO: Eventually make it so that this thing also takes individual usage into account, so we can show per-interface!
pub async fn get_network_data(
prev_net_access_time: Instant, prev_net_rx: &mut u64, prev_net_tx: &mut u64,
diff --git a/src/app/data_harvester/network/sysinfo.rs b/src/app/data_harvester/network/sysinfo.rs
index 634cf779..e3aea9e7 100644
--- a/src/app/data_harvester/network/sysinfo.rs
+++ b/src/app/data_harvester/network/sysinfo.rs
@@ -1,8 +1,9 @@
//! Gets network data via sysinfo.
-use super::NetworkHarvest;
use std::time::Instant;
+use super::NetworkHarvest;
+
pub async fn get_network_data(
sys: &sysinfo::System, prev_net_access_time: Instant, prev_net_rx: &mut u64,
prev_net_tx: &mut u64, curr_time: Instant, actually_get: bool,
diff --git a/src/app/data_harvester/processes/freebsd.rs b/src/app/data_harvester/processes/freebsd.rs
index 9250c308..49816bc2 100644
--- a/src/app/data_harvester/processes/freebsd.rs
+++ b/src/app/data_harvester/processes/freebsd.rs
@@ -1,11 +1,11 @@
//! Process data collection for FreeBSD. Uses sysinfo.
-use serde::{Deserialize, Deserializer};
use std::io;
-use super::ProcessHarvest;
+use serde::{Deserialize, Deserializer};
use sysinfo::System;
+use super::ProcessHarvest;
use crate::data_harvester::deserialize_xo;
use crate::data_harvester::processes::UserTable;
diff --git a/src/app/data_harvester/processes/linux.rs b/src/app/data_harvester/processes/linux.rs
index a2e5e253..6b2875f8 100644
--- a/src/app/data_harvester/processes/linux.rs
+++ b/src/app/data_harvester/processes/linux.rs
@@ -2,18 +2,15 @@
use std::collections::hash_map::Entry;
+use fxhash::{FxHashMap, FxHashSet};
+use procfs::process::{Process, Stat};
+use sysinfo::ProcessStatus;
+
+use super::{ProcessHarvest, UserTable};
use crate::components::tui_widget::time_chart::Point;
use crate::utils::error::{self, BottomError};
use crate::Pid;
-use super::{ProcessHarvest, UserTable};
-
-use sysinfo::ProcessStatus;
-
-use procfs::process::{Process, Stat};
-
-use fxhash::{FxHashMap, FxHashSet};
-
/// Maximum character length of a /proc/<PID>/stat process name.
/// If it's equal or greater, then we instead refer to the command for the name.
const MAX_STAT_NAME_LEN: usize = 15;
diff --git a/src/app/data_harvester/processes/macos.rs b/src/app/data_harvester/processes/macos.rs
index 80ded85e..d0847a1b 100644
--- a/src/app/data_harvester/processes/macos.rs
+++ b/src/app/data_harvester/processes/macos.rs
@@ -1,8 +1,8 @@
//! Process data collection for macOS. Uses sysinfo and custom bindings.
-use super::ProcessHarvest;
use sysinfo::System;
+use super::ProcessHarvest;
use crate::{data_harvester::processes::UserTable, Pid};
mod sysctl_bindings;
diff --git a/src/app/data_harvester/processes/macos/sysctl_bindings.rs b/src/app/data_harvester/processes/macos/sysctl_bindings.rs
index 22bc07c6..e56d79b8 100644
--- a/src/app/data_harvester/processes/macos/sysctl_bindings.rs
+++ b/src/app/data_harvester/processes/macos/sysctl_bindings.rs
@@ -295,9 +295,10 @@ pub(crate) fn kinfo_process(pid: Pid) -> Result<kinfo_proc> {
#[cfg(test)]
mod test {
- use super::*;
use std::mem;
+ use super::*;
+
/// A quick test to ensure that things are sized correctly.
#[test]
fn test_struct_sizes() {
diff --git a/src/app/data_harvester/processes/macos_freebsd.rs b/src/app/data_harvester/processes/macos_freebsd.rs
index 65725732..588d49dc 100644
--- a/src/app/data_harvester/processes/macos_freebsd.rs
+++ b/src/app/data_harvester/processes/macos_freebsd.rs
@@ -3,9 +3,9 @@
use std::collections::HashMap;
use std::io;
-use super::ProcessHarvest;
use sysinfo::{CpuExt, PidExt, ProcessExt, ProcessStatus, System, SystemExt};
+use super::ProcessHarvest;
use crate::{data_harvester::processes::UserTable, utils::error::Result, Pid};
pub fn get_process_data<F>(
diff --git a/src/app/data_harvester/processes/windows.rs b/src/app/data_harvester/processes/windows.rs
index 4df40983..7eac0411 100644
--- a/src/app/data_harvester/processes/windows.rs
+++ b/src/app/data_harvester/processes/windows.rs
@@ -1,8 +1,9 @@
//! Process data collection for Windows. Uses sysinfo.
-use super::ProcessHarvest;
use sysinfo::{CpuExt, PidExt, ProcessExt, System, SystemExt};
+use super::ProcessHarvest;
+
pub fn get_process_data(
sys: &System, use_current_cpu_total: bool, mem_total_kb: u64,
) -> crate::utils::error::Result<Vec<ProcessHarvest>> {
diff --git a/src/app/data_harvester/temperature/linux.rs b/src/app/data_harvester/temperature/linux.rs
index 5fec1059..0bca3649 100644
--- a/src/app/data_harvester/temperature/linux.rs
+++ b/src/app/data_harvester/temperature/linux.rs
@@ -1,12 +1,14 @@
//! Gets temperature sensor data for Linux platforms.
+use std::{fs, path::Path};
+
+use anyhow::{anyhow, Result};
+
use super::{is_temp_filtered, temp_vec_sort, TempHarvest, TemperatureType};
use crate::app::{
data_harvester::temperature::{convert_celsius_to_fahrenheit, convert_celsius_to_kelvin},
Filter,
};
-use anyhow::{anyhow, Result};
-use std::{fs, path::Path};
/// Get temperature sensors from the linux sysfs interface `/sys/class/hwmon`.
/// See [here](https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-hwmon) for
diff --git a/src/app/data_harvester/temperature/nvidia.rs b/src/app/data_harvester/temperature/nvidia.rs
index 049708b7..be51e45b 100644
--- a/src/app/data_harvester/temperature/nvidia.rs
+++ b/src/app/data_harvester/temperature/nvidia.rs
@@ -1,12 +1,10 @@
-use crate::app::Filter;
+use nvml_wrapper::enum_wrappers::device::TemperatureSensor;
use super::{
convert_celsius_to_fahrenheit, convert_celsius_to_kelvin, is_temp_filtered, TempHarvest,
TemperatureType,
};
-
-use nvml_wrapper::enum_wrappers::device::TemperatureSensor;
-
+use crate::app::Filter;
use crate::data_harvester::nvidia::NVML_DATA;
pub fn add_nvidia_data(
diff --git a/src/app/data_harvester/temperature/sysinfo.rs b/src/app/data_harvester/temperature/sysinfo.rs
index 42ed1a68..83a15094 100644
--- a/src/app/data_harvester/temperature/sysinfo.rs
+++ b/src/app/data_harvester/temperature/sysinfo.rs
@@ -1,11 +1,12 @@
//! Gets temperature data via sysinfo.
+use anyhow::Result;
+
use super::{
convert_celsius_to_fahrenheit, convert_celsius_to_kelvin, is_temp_filtered, temp_vec_sort,
TempHarvest, TemperatureType,
};
use crate::app::Filter;
-use anyhow::Result;
pub fn get_temperature_data(
sys: &sysinfo::System, temp_type: &TemperatureType, filter: &Option<Filter>,
diff --git a/src/app/layout_manager.rs b/src/app/layout_manager.rs
index 916a3d5b..fab2d918 100644
--- a/src/app/layout_manager.rs
+++ b/src/app/layout_manager.rs
@@ -1,8 +1,9 @@
-use crate::error::{BottomError, Result};
use std::collections::BTreeMap;
+
use typed_builder::*;
use crate::constants::DEFAULT_WIDGET_ID;
+use crate::error::{BottomError, Result};
/// Represents a more usable representation of the layout, derived from the
/// config.
diff --git a/src/app/query.rs b/src/app/query.rs
index 46c40022..0eca1b75 100644
--- a/src/app/query.rs
+++ b/src/app/query.rs
@@ -1,11 +1,11 @@
-use crate::utils::error::{
- BottomError::{self, QueryError},
- Result,
-};
use std::fmt::Debug;
use std::{borrow::Cow, collections::VecDeque};
use super::data_harvester::processes::ProcessHarvest;
+use crate::utils::error::{
+ BottomError::{self, QueryError},
+ Result,
+};
const DELIMITER_LIST: [char; 6] = ['=', '>', '<', '(', ')', '\"'];
const COMPARISON_LIST: [&str; 3] = [">", "=", "<"];
diff --git a/src/app/states.rs b/src/app/states.rs
index 63b9bae8..4c3e6e28 100644
--- a/src/app/states.rs
+++ b/src/app/states.rs
@@ -2,15 +2,14 @@ use std::{collections::HashMap, time::Instant};
use unicode_segmentation::GraphemeCursor;
-use crate::{
- app::{layout_manager::BottomWidgetType, query::*},
- constants,
-};
-
use super::widgets::{
BatteryWidgetState, CpuWidgetState, DiskTableWidget, MemWidgetState, NetWidgetState,
ProcWidget, TempWidgetState,
};
+use crate::{
+ app::{layout_manager::BottomWidgetType, query::*},
+ constants,
+};
#[derive(Debug)]
pub enum CursorDirection {
diff --git a/src/app/widgets/cpu_graph.rs b/src/app/widgets/cpu_graph.rs
index 5e895edc..7f0c1495 100644
--- a/src/app/widgets/cpu_graph.rs
+++ b/src/app/widgets/cpu_graph.rs
@@ -1,7 +1,6 @@
use std::{borrow::Cow, time::Instant};
use concat_string::concat_string;
-
use tui::{style::Style, text::Text, widgets::Row};
use crate::{
diff --git a/src/app/widgets/process_table.rs b/src/app/widgets/process_table.rs
index 970e1cc5..cb630aac 100644
--- a/src/app/widgets/process_table.rs
+++ b/src/app/widgets/process_table.rs
@@ -1,5 +1,8 @@
use std::borrow::Cow;
+use fxhash::{FxHashMap, FxHashSet};
+use itertools::Itertools;
+
use crate::{
app::{
data_farmer::{DataCollection, ProcessData},
@@ -15,9 +18,6 @@ use crate::{
Pid,
};
-use fxhash::{FxHashMap, FxHashSet};
-use itertools::Itertools;
-
pub mod proc_widget_column;
pub use proc_widget_column::*;
diff --git a/src/app/widgets/process_table/proc_widget_column.rs b/src/app/widgets/process_table/proc_widget_column.rs
index 4830bc65..691aec02 100644
--- a/src/app/widgets/process_table/proc_widget_column.rs
+++ b/src/app/widgets/process_table/proc_widget_column.rs
@@ -1,12 +1,11 @@
+use std::{borrow::Cow, cmp::Reverse};
+
+use super::ProcWidgetData;
use crate::{
components::data_table::{ColumnHeader, SortsRow},
utils::gen_util::sort_partial_fn,
};
-use std::{borrow::Cow, cmp::Reverse};
-
-use super::ProcWidgetData;
-
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub enum ProcColumn {
CpuPercent,
diff --git a/src/app/widgets/process_table/proc_widget_data.rs b/src/app/widgets/process_table/proc_widget_data.rs
index 4957c87f..acb33af4 100644
--- a/src/app/widgets/process_table/proc_widget_data.rs
+++ b/src/app/widgets/process_table/proc_widget_data.rs
@@ -6,6 +6,7 @@ use std::{
use concat_string::concat_string;
use tui::{text::Text, widgets::Row};
+use super::proc_widget_column::ProcColumn;
use crate::{
app::data_harvester::processes::ProcessHarvest,
canvas::Painter,
@@ -15,8 +16,6 @@ use crate::{
Pid,
};
-use super::proc_widget_column::ProcColumn;
-
#[derive(Clone)]
enum IdType {
Name(String),
diff --git a/src/bin/main.rs b/src/bin/main.rs
index feef550a..a1fdcbc1 100644
--- a/src/bin/main.rs
+++ b/src/bin/main.rs
@@ -4,14 +4,6 @@
#[macro_use]
extern crate log;
-use bottom::{
- canvas::{self, canvas_colours::CanvasColours},
- constants::*,
- data_conversion::*,
- options::*,
- *,
-};
-
use std::{
boxed::Box,
io::stdout,
@@ -25,6 +17,13 @@ use std::{
};
use anyhow::{Context, Result};
+use bottom::{
+ canvas::{self, canvas_colours::CanvasColours},
+ constants::*,
+ data_conversion::*,
+ options::*,
+ *,
+};
use crossterm::{
event::{EnableBracketedPaste, EnableMouseCapture},
execute,
diff --git a/src/canvas.rs b/src/canvas.rs
index c9312700..c7508802 100644
--- a/src/canvas.rs
+++ b/src/canvas.rs
@@ -1,6 +1,7 @@
-use itertools::izip;
use std::str::FromStr;
+use canvas_colours::*;
+use itertools::izip;
use tui::{
backend::Backend,
layout::{Constraint, Direction, Layout, Rect},
@@ -9,8 +10,6 @@ use tui::{
Frame, Terminal,
};
-use canvas_colours::*;
-
use crate::{
app::{
self,
diff --git a/src/canvas/canvas_colours.rs b/src/canvas/canvas_colours.rs
index 1fa9ce3a..6a43a305 100644
--- a/src/canvas/canvas_colours.rs
+++ b/src/canvas/canvas_colours.rs
@@ -1,13 +1,13 @@
-use crate::{
- constants::*,
- options::{Config, ConfigColours},
- utils::error,
-};
use anyhow::Context;
use colour_utils::*;
use tui::style::{Color, Style};
use super::ColourScheme;
+use crate::{
+ constants::*,
+ options::{Config, ConfigColours},
+ utils::error,
+};
mod colour_utils;
pub struct CanvasColours {
diff --git a/src