refactor: somewhat migrate to Rust 2024 edition (#1681)

* refactor: try bumping to rust 2024 edition

* now run nightly fmt

* fix some macos changes

* only apply a few of these settings
This commit is contained in:
Clement Tsang 2025-02-21 21:12:08 -05:00 committed by GitHub
parent 9999a4824a
commit f7d070f944
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
62 changed files with 207 additions and 198 deletions

View File

@ -10,7 +10,7 @@ use std::{
}; };
use clap::{Command, CommandFactory}; use clap::{Command, CommandFactory};
use clap_complete::{generate_to, shells::Shell, Generator}; use clap_complete::{Generator, generate_to, shells::Shell};
use clap_complete_fig::Fig; use clap_complete_fig::Fig;
use clap_complete_nushell::Nushell; use clap_complete_nushell::Nushell;

View File

@ -5,6 +5,7 @@ fn_params_layout = "Compressed"
use_field_init_shorthand = true use_field_init_shorthand = true
tab_spaces = 4 tab_spaces = 4
max_width = 100 max_width = 100
style_edition = "2024"
# Unstable options, disabled by default. # Unstable options, disabled by default.
# imports_granularity = "Crate" # imports_granularity = "Crate"

View File

@ -1,8 +1,9 @@
use std::{collections::BTreeMap, vec::Vec}; use std::{collections::BTreeMap, vec::Vec};
use crate::collection::processes::{Pid, ProcessHarvest};
use hashbrown::HashMap; use hashbrown::HashMap;
use crate::collection::processes::{Pid, ProcessHarvest};
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default)]
pub struct ProcessData { pub struct ProcessData {
/// A PID to process data map. /// A PID to process data map.

View File

@ -3,18 +3,17 @@ use std::{
vec::Vec, vec::Vec,
}; };
use super::{ProcessData, TimeSeriesData};
#[cfg(feature = "battery")] #[cfg(feature = "battery")]
use crate::collection::batteries; use crate::collection::batteries;
use crate::{ use crate::{
app::AppConfigFields, app::AppConfigFields,
collection::{cpu, disks, memory::MemData, network, Data}, collection::{Data, cpu, disks, memory::MemData, network},
dec_bytes_per_second_string, dec_bytes_per_second_string,
utils::data_units::DataUnit, utils::data_units::DataUnit,
widgets::{DiskWidgetData, TempWidgetData}, widgets::{DiskWidgetData, TempWidgetData},
}; };
use super::{ProcessData, TimeSeriesData};
/// A collection of data. This is where we dump data into. /// A collection of data. This is where we dump data into.
/// ///
/// TODO: Maybe reduce visibility of internal data, make it only accessible through DataStore? /// TODO: Maybe reduce visibility of internal data, make it only accessible through DataStore?
@ -186,7 +185,7 @@ impl StoredData {
{ {
if !device.name.starts_with('/') { if !device.name.starts_with('/') {
Some(device.name.as_str()) // use the whole zfs Some(device.name.as_str()) // use the whole zfs
// dataset name // dataset name
} else { } else {
device.name.split('/').last() device.name.split('/').last()
} }

View File

@ -663,21 +663,20 @@ impl BottomLayout {
BottomLayout { BottomLayout {
total_row_height_ratio: 3, total_row_height_ratio: 3,
rows: vec![ rows: vec![
BottomRow::new(vec![BottomCol::new(vec![ BottomRow::new(vec![
BottomColRow::new(vec![cpu]).canvas_handled() BottomCol::new(vec![BottomColRow::new(vec![cpu]).canvas_handled()])
.canvas_handled(),
]) ])
.canvas_handled()])
.canvas_handled(), .canvas_handled(),
BottomRow::new(vec![BottomCol::new(vec![BottomColRow::new(vec![ BottomRow::new(vec![
mem, net, BottomCol::new(vec![BottomColRow::new(vec![mem, net]).canvas_handled()])
.canvas_handled(),
]) ])
.canvas_handled()])
.canvas_handled()])
.canvas_handled(), .canvas_handled(),
BottomRow::new(vec![BottomCol::new(vec![ BottomRow::new(vec![
BottomColRow::new(vec![table]).canvas_handled() BottomCol::new(vec![BottomColRow::new(vec![table]).canvas_handled()])
.canvas_handled(),
]) ])
.canvas_handled()])
.canvas_handled(), .canvas_handled(),
BottomRow::new(table_widgets).canvas_handled(), BottomRow::new(table_widgets).canvas_handled(),
], ],

View File

@ -6,7 +6,7 @@ use anyhow::bail;
use windows::Win32::{ use windows::Win32::{
Foundation::{CloseHandle, HANDLE}, Foundation::{CloseHandle, HANDLE},
System::Threading::{ System::Threading::{
OpenProcess, TerminateProcess, PROCESS_QUERY_INFORMATION, PROCESS_TERMINATE, OpenProcess, PROCESS_QUERY_INFORMATION, PROCESS_TERMINATE, TerminateProcess,
}, },
}; };
@ -68,9 +68,11 @@ pub fn kill_process_given_pid(pid: Pid, signal: usize) -> anyhow::Result<()> {
let err_code = std::io::Error::last_os_error().raw_os_error(); let err_code = std::io::Error::last_os_error().raw_os_error();
let err = match err_code { let err = match err_code {
Some(libc::ESRCH) => "the target process did not exist.", Some(libc::ESRCH) => "the target process did not exist.",
Some(libc::EPERM) => "the calling process does not have the permissions to terminate the target process(es).", Some(libc::EPERM) => {
"the calling process does not have the permissions to terminate the target process(es)."
}
Some(libc::EINVAL) => "an invalid signal was specified.", Some(libc::EINVAL) => "an invalid signal was specified.",
_ => "Unknown error occurred." _ => "Unknown error occurred.",
}; };
if let Some(err_code) = err_code { if let Some(err_code) = err_code {

View File

@ -9,8 +9,8 @@ use crate::{
app::layout_manager::BottomWidgetType, app::layout_manager::BottomWidgetType,
constants, constants,
widgets::{ widgets::{
query::ProcessQuery, BatteryWidgetState, CpuWidgetState, DiskTableWidget, MemWidgetState, BatteryWidgetState, CpuWidgetState, DiskTableWidget, MemWidgetState, NetWidgetState,
NetWidgetState, ProcWidgetState, TempWidgetState, ProcWidgetState, TempWidgetState, query::ProcessQuery,
}, },
}; };

View File

@ -5,17 +5,17 @@ mod widgets;
use itertools::izip; use itertools::izip;
use tui::{ use tui::{
Frame, Terminal,
backend::Backend, backend::Backend,
layout::{Constraint, Direction, Layout, Rect}, layout::{Constraint, Direction, Layout, Rect},
text::Span, text::Span,
widgets::Paragraph, widgets::Paragraph,
Frame, Terminal,
}; };
use crate::{ use crate::{
app::{ app::{
layout_manager::{BottomColRow, BottomLayout, BottomWidgetType, IntermediaryConstraint},
App, App,
layout_manager::{BottomColRow, BottomLayout, BottomWidgetType, IntermediaryConstraint},
}, },
constants::*, constants::*,
options::config::style::Styles, options::config::style::Styles,
@ -362,11 +362,7 @@ impl Painter {
&& actual_cpu_data_len.saturating_sub(1) % 4 != 0, && actual_cpu_data_len.saturating_sub(1) % 4 != 0,
); );
if c <= 1 { if c <= 1 { 1 } else { c }
1
} else {
c
}
}; };
let mut mem_rows = 1; let mut mem_rows = 1;

View File

@ -5,10 +5,10 @@ use std::{
use concat_string::concat_string; use concat_string::concat_string;
use tui::{ use tui::{
Frame,
layout::{Constraint, Direction, Layout, Rect}, layout::{Constraint, Direction, Layout, Rect},
text::{Line, Span, Text}, text::{Line, Span, Text},
widgets::{Block, Row, Table}, widgets::{Block, Row, Table},
Frame,
}; };
use super::{ use super::{
@ -17,7 +17,7 @@ use super::{
}; };
use crate::{ use crate::{
app::layout_manager::BottomWidget, app::layout_manager::BottomWidget,
canvas::{drawing_utils::widget_block, Painter}, canvas::{Painter, drawing_utils::widget_block},
constants::TABLE_GAP_HEIGHT_LIMIT, constants::TABLE_GAP_HEIGHT_LIMIT,
utils::strings::truncate_to_text, utils::strings::truncate_to_text,
}; };

View File

@ -1,16 +1,15 @@
mod time_chart; mod time_chart;
pub use time_chart::*;
use std::{borrow::Cow, time::Instant}; use std::{borrow::Cow, time::Instant};
use concat_string::concat_string; use concat_string::concat_string;
pub use time_chart::*;
use tui::{ use tui::{
Frame,
layout::{Constraint, Rect}, layout::{Constraint, Rect},
style::Style, style::Style,
symbols::Marker, symbols::Marker,
text::{Line, Span}, text::{Line, Span},
widgets::{BorderType, GraphType}, widgets::{BorderType, GraphType},
Frame,
}; };
use crate::{app::data::Values, canvas::drawing_utils::widget_block}; use crate::{app::data::Values, canvas::drawing_utils::widget_block};

View File

@ -16,13 +16,13 @@ use tui::{
style::{Color, Style, Styled}, style::{Color, Style, Styled},
symbols::{self, Marker}, symbols::{self, Marker},
text::{Line, Span}, text::{Line, Span},
widgets::{block::BlockExt, Block, Borders, GraphType, Widget}, widgets::{Block, Borders, GraphType, Widget, block::BlockExt},
}; };
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
use crate::{ use crate::{
app::data::Values, app::data::Values,
utils::general::{saturating_log10, saturating_log2}, utils::general::{saturating_log2, saturating_log10},
}; };
pub const DEFAULT_LEGEND_CONSTRAINTS: (Constraint, Constraint) = pub const DEFAULT_LEGEND_CONSTRAINTS: (Constraint, Constraint) =
@ -1116,7 +1116,7 @@ mod tests {
assert!(layout.legend_area.is_some()); assert!(layout.legend_area.is_some());
assert_eq!(layout.legend_area.unwrap().height, 4); // 2 for borders, 2 assert_eq!(layout.legend_area.unwrap().height, 4); // 2 for borders, 2
// for rows // for rows
} }
#[test] #[test]

View File

@ -22,8 +22,8 @@ use tui::{
symbols, symbols,
text::Line, text::Line,
widgets::{ widgets::{
canvas::{Line as CanvasLine, Points},
Block, Widget, Block, Widget,
canvas::{Line as CanvasLine, Points},
}, },
}; };

View File

@ -2,8 +2,8 @@ use itertools::Itertools;
use tui::{ use tui::{
style::Color, style::Color,
widgets::{ widgets::{
canvas::{Line as CanvasLine, Points},
GraphType, GraphType,
canvas::{Line as CanvasLine, Points},
}, },
}; };

View File

@ -1,12 +1,12 @@
use tui::{ use tui::{
Frame,
layout::{Alignment, Constraint, Direction, Layout, Rect}, layout::{Alignment, Constraint, Direction, Layout, Rect},
text::{Line, Span}, text::{Line, Span},
widgets::{Block, Paragraph}, widgets::{Block, Paragraph},
Frame,
}; };
use crate::{ use crate::{
app::{layout_manager::BottomWidgetType, App}, app::{App, layout_manager::BottomWidgetType},
canvas::Painter, canvas::Painter,
}; };

View File

@ -2,15 +2,15 @@
use std::cmp::min; use std::cmp::min;
use tui::{ use tui::{
Frame,
layout::{Alignment, Constraint, Direction, Layout, Rect}, layout::{Alignment, Constraint, Direction, Layout, Rect},
text::{Line, Span, Text}, text::{Line, Span, Text},
widgets::{Block, Paragraph, Wrap}, widgets::{Block, Paragraph, Wrap},
Frame,
}; };
use crate::{ use crate::{
app::{App, KillSignal, MAX_PROCESS_SIGNAL}, app::{App, KillSignal, MAX_PROCESS_SIGNAL},
canvas::{drawing_utils::dialog_block, Painter}, canvas::{Painter, drawing_utils::dialog_block},
widgets::ProcWidgetMode, widgets::ProcWidgetMode,
}; };

View File

@ -1,16 +1,16 @@
use std::cmp::{max, min}; use std::cmp::{max, min};
use tui::{ use tui::{
Frame,
layout::{Alignment, Rect}, layout::{Alignment, Rect},
text::{Line, Span}, text::{Line, Span},
widgets::{Paragraph, Wrap}, widgets::{Paragraph, Wrap},
Frame,
}; };
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
use crate::{ use crate::{
app::App, app::App,
canvas::{drawing_utils::dialog_block, Painter}, canvas::{Painter, drawing_utils::dialog_block},
constants::{self, HELP_TEXT}, constants::{self, HELP_TEXT},
}; };

View File

@ -1,16 +1,16 @@
use std::cmp::min; use std::cmp::min;
use tui::{ use tui::{
Frame,
layout::{Constraint, Direction, Layout, Rect}, layout::{Constraint, Direction, Layout, Rect},
text::{Line, Span}, text::{Line, Span},
widgets::{Cell, Paragraph, Row, Table, Tabs}, widgets::{Cell, Paragraph, Row, Table, Tabs},
Frame,
}; };
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
use crate::{ use crate::{
app::App, app::App,
canvas::{drawing_utils::widget_block, Painter}, canvas::{Painter, drawing_utils::widget_block},
collection::batteries::BatteryState, collection::batteries::BatteryState,
constants::*, constants::*,
}; };

View File

@ -2,16 +2,16 @@ use std::cmp::min;
use itertools::{Either, Itertools}; use itertools::{Either, Itertools};
use tui::{ use tui::{
layout::{Constraint, Direction, Layout, Rect},
Frame, Frame,
layout::{Constraint, Direction, Layout, Rect},
}; };
use crate::{ use crate::{
app::App, app::App,
canvas::{ canvas::{
Painter,
components::pipe_gauge::{LabelLimit, PipeGauge}, components::pipe_gauge::{LabelLimit, PipeGauge},
drawing_utils::widget_block, drawing_utils::widget_block,
Painter,
}, },
collection::cpu::{CpuData, CpuDataType}, collection::cpu::{CpuData, CpuDataType},
}; };

View File

@ -1,20 +1,20 @@
use std::borrow::Cow; use std::borrow::Cow;
use tui::{ use tui::{
Frame,
layout::{Constraint, Direction, Layout, Rect}, layout::{Constraint, Direction, Layout, Rect},
symbols::Marker, symbols::Marker,
Frame,
}; };
use crate::{ use crate::{
app::{data::StoredData, layout_manager::WidgetDirection, App}, app::{App, data::StoredData, layout_manager::WidgetDirection},
canvas::{ canvas::{
Painter,
components::{ components::{
data_table::{DrawInfo, SelectionState}, data_table::{DrawInfo, SelectionState},
time_graph::{AxisBound, GraphData, TimeGraph}, time_graph::{AxisBound, GraphData, TimeGraph},
}, },
drawing_utils::should_hide_x_label, drawing_utils::should_hide_x_label,
Painter,
}, },
collection::cpu::CpuData, collection::cpu::CpuData,
widgets::CpuWidgetState, widgets::CpuWidgetState,
@ -158,10 +158,12 @@ impl Painter {
[(offset_position - show_avg_offset) % self.styles.cpu_colour_styles.len()] [(offset_position - show_avg_offset) % self.styles.cpu_colour_styles.len()]
}; };
vec![GraphData::default() vec![
.style(style) GraphData::default()
.time(time) .style(style)
.values(&cpu_points[current_scroll_position - 1])] .time(time)
.values(&cpu_points[current_scroll_position - 1]),
]
} else { } else {
vec![] vec![]
} }

View File

@ -1,10 +1,10 @@
use tui::{layout::Rect, Frame}; use tui::{Frame, layout::Rect};
use crate::{ use crate::{
app, app,
canvas::{ canvas::{
components::data_table::{DrawInfo, SelectionState},
Painter, Painter,
components::data_table::{DrawInfo, SelectionState},
}, },
}; };

View File

@ -1,13 +1,13 @@
use std::borrow::Cow; use std::borrow::Cow;
use tui::{ use tui::{
layout::{Constraint, Direction, Layout, Rect},
Frame, Frame,
layout::{Constraint, Direction, Layout, Rect},
}; };
use crate::{ use crate::{
app::App, app::App,
canvas::{components::pipe_gauge::PipeGauge, drawing_utils::widget_block, Painter}, canvas::{Painter, components::pipe_gauge::PipeGauge, drawing_utils::widget_block},
collection::memory::MemData, collection::memory::MemData,
get_binary_unit_and_denominator, get_binary_unit_and_denominator,
}; };

View File

@ -1,18 +1,18 @@
use std::{borrow::Cow, time::Instant}; use std::{borrow::Cow, time::Instant};
use tui::{ use tui::{
Frame,
layout::{Constraint, Rect}, layout::{Constraint, Rect},
style::Style, style::Style,
symbols::Marker, symbols::Marker,
Frame,
}; };
use crate::{ use crate::{
app::{data::Values, App}, app::{App, data::Values},
canvas::{ canvas::{
Painter,
components::time_graph::{AxisBound, GraphData, TimeGraph}, components::time_graph::{AxisBound, GraphData, TimeGraph},
drawing_utils::should_hide_x_label, drawing_utils::should_hide_x_label,
Painter,
}, },
collection::memory::MemData, collection::memory::MemData,
get_binary_unit_and_denominator, get_binary_unit_and_denominator,

View File

@ -1,13 +1,13 @@
use tui::{ use tui::{
Frame,
layout::{Constraint, Direction, Layout, Rect}, layout::{Constraint, Direction, Layout, Rect},
text::{Line, Span}, text::{Line, Span},
widgets::{Block, Paragraph}, widgets::{Block, Paragraph},
Frame,
}; };
use crate::{ use crate::{
app::App, app::App,
canvas::{drawing_utils::widget_block, Painter}, canvas::{Painter, drawing_utils::widget_block},
utils::data_units::{convert_bits, get_unit_prefix}, utils::data_units::{convert_bits, get_unit_prefix},
}; };

View File

@ -1,23 +1,23 @@
use std::time::Duration; use std::time::Duration;
use tui::{ use tui::{
Frame,
layout::{Constraint, Direction, Layout, Rect}, layout::{Constraint, Direction, Layout, Rect},
symbols::Marker, symbols::Marker,
text::Text, text::Text,
widgets::{Block, Borders, Row, Table}, widgets::{Block, Borders, Row, Table},
Frame,
}; };
use crate::{ use crate::{
app::{App, AppConfigFields, AxisScaling}, app::{App, AppConfigFields, AxisScaling},
canvas::{ canvas::{
Painter,
components::time_graph::{AxisBound, ChartScaling, GraphData, TimeGraph}, components::time_graph::{AxisBound, ChartScaling, GraphData, TimeGraph},
drawing_utils::should_hide_x_label, drawing_utils::should_hide_x_label,
Painter,
}, },
utils::{ utils::{
data_units::*, data_units::*,
general::{saturating_log10, saturating_log2}, general::{saturating_log2, saturating_log10},
}, },
widgets::NetWidgetHeightCache, widgets::NetWidgetHeightCache,
}; };
@ -106,7 +106,7 @@ impl Painter {
for (&time, &v) in rx_points for (&time, &v) in rx_points
.iter_along_base(time) .iter_along_base(time)
.rev() .rev()
.take_while(|(&time, _)| time >= first_time) .take_while(|&(&time, _)| time >= first_time)
{ {
if v > biggest { if v > biggest {
biggest = v; biggest = v;
@ -117,7 +117,7 @@ impl Painter {
for (&time, &v) in tx_points for (&time, &v) in tx_points
.iter_along_base(time) .iter_along_base(time)
.rev() .rev()
.take_while(|(&time, _)| time >= first_time) .take_while(|&(&time, _)| time >= first_time)
{ {
if v > biggest { if v > biggest {
biggest = v; biggest = v;

View File

@ -1,18 +1,18 @@
use tui::{ use tui::{
Frame,
layout::{Alignment, Constraint, Direction, Layout, Rect}, layout::{Alignment, Constraint, Direction, Layout, Rect},
style::Style, style::Style,
text::{Line, Span}, text::{Line, Span},
widgets::Paragraph, widgets::Paragraph,
Frame,
}; };
use unicode_segmentation::UnicodeSegmentation; use unicode_segmentation::UnicodeSegmentation;
use crate::{ use crate::{
app::{App, AppSearchState}, app::{App, AppSearchState},
canvas::{ canvas::{
Painter,
components::data_table::{DrawInfo, SelectionState}, components::data_table::{DrawInfo, SelectionState},
drawing_utils::widget_block, drawing_utils::widget_block,
Painter,
}, },
}; };

View File

@ -1,10 +1,10 @@
use tui::{layout::Rect, Frame}; use tui::{Frame, layout::Rect};
use crate::{ use crate::{
app, app,
canvas::{ canvas::{
components::data_table::{DrawInfo, SelectionState},
Painter, Painter,
components::data_table::{DrawInfo, SelectionState},
}, },
}; };

View File

@ -1,10 +1,5 @@
mod amdgpu_marketing; mod amdgpu_marketing;
use crate::{
app::{filter::Filter, layout_manager::UsedWidgets},
collection::{memory::MemData, temperature::TempSensorData},
};
use hashbrown::{HashMap, HashSet};
use std::{ use std::{
fs::{self, read_to_string}, fs::{self, read_to_string},
num::NonZeroU64, num::NonZeroU64,
@ -13,6 +8,13 @@ use std::{
time::{Duration, Instant}, time::{Duration, Instant},
}; };
use hashbrown::{HashMap, HashSet};
use crate::{
app::{filter::Filter, layout_manager::UsedWidgets},
collection::{memory::MemData, temperature::TempSensorData},
};
// TODO: May be able to clean up some of these, Option<Vec> for example is a bit redundant. // TODO: May be able to clean up some of these, Option<Vec> for example is a bit redundant.
pub struct AMDGPUData { pub struct AMDGPUData {
pub memory: Option<Vec<(String, MemData)>>, pub memory: Option<Vec<(String, MemData)>>,

View File

@ -11,8 +11,8 @@
//! For more information, refer to the [starship_battery](https://github.com/starship/rust-battery) repo/docs. //! For more information, refer to the [starship_battery](https://github.com/starship/rust-battery) repo/docs.
use starship_battery::{ use starship_battery::{
units::{power::watt, ratio::percent, time::second},
Battery, Manager, State, Battery, Manager, State,
units::{power::watt, ratio::percent, time::second},
}; };
/// Battery state. /// Battery state.

View File

@ -5,8 +5,8 @@ use std::io;
use hashbrown::HashMap; use hashbrown::HashMap;
use serde::Deserialize; use serde::Deserialize;
use super::{keep_disk_entry, DiskHarvest, IoHarvest}; use super::{DiskHarvest, IoHarvest, keep_disk_entry};
use crate::collection::{deserialize_xo, disks::IoData, error::CollectionResult, DataCollector}; use crate::collection::{DataCollector, deserialize_xo, disks::IoData, error::CollectionResult};
#[derive(Deserialize, Debug, Default)] #[derive(Deserialize, Debug, Default)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]

View File

@ -1,6 +1,6 @@
//! Fallback disk info using sysinfo. //! Fallback disk info using sysinfo.
use super::{keep_disk_entry, DiskHarvest}; use super::{DiskHarvest, keep_disk_entry};
use crate::collection::DataCollector; use crate::collection::DataCollector;
pub(crate) fn get_disk_usage(collector: &DataCollector) -> anyhow::Result<Vec<DiskHarvest>> { pub(crate) fn get_disk_usage(collector: &DataCollector) -> anyhow::Result<Vec<DiskHarvest>> {

View File

@ -24,7 +24,7 @@ cfg_if::cfg_if! {
use file_systems::*; use file_systems::*;
use usage::*; use usage::*;
use super::{keep_disk_entry, DiskHarvest}; use super::{DiskHarvest, keep_disk_entry};
use crate::collection::DataCollector; use crate::collection::DataCollector;
/// Returns the disk usage of the mounted (and for now, physical) disks. /// Returns the disk usage of the mounted (and for now, physical) disks.

View File

@ -6,7 +6,7 @@
//! Ideally, we can remove this if sysinfo ever gains disk I/O capabilities. //! Ideally, we can remove this if sysinfo ever gains disk I/O capabilities.
use core_foundation::{ use core_foundation::{
base::{mach_port_t, CFAllocatorRef}, base::{CFAllocatorRef, mach_port_t},
dictionary::CFMutableDictionaryRef, dictionary::CFMutableDictionaryRef,
}; };
use libc::c_char; use libc::c_char;
@ -32,8 +32,9 @@ pub const kIOServicePlane: &str = "IOService\0";
#[expect(non_upper_case_globals)] #[expect(non_upper_case_globals)]
pub const kIOMediaClass: &str = "IOMedia\0"; pub const kIOMediaClass: &str = "IOMedia\0";
// See [here](https://developer.apple.com/documentation/iokit) for more details. // SAFETY: Bindings like this are inherently unsafe. See [here](https://developer.apple.com/documentation/iokit) for
extern "C" { // more details.
unsafe extern "C" {
pub fn IOServiceGetMatchingServices( pub fn IOServiceGetMatchingServices(
mainPort: mach_port_t, matching: CFMutableDictionaryRef, existing: *mut io_iterator_t, mainPort: mach_port_t, matching: CFMutableDictionaryRef, existing: *mut io_iterator_t,

View File

@ -1,7 +1,7 @@
use anyhow::bail; use anyhow::bail;
use mach2::kern_return; use mach2::kern_return;
use super::{bindings::*, IoIterator}; use super::{IoIterator, bindings::*};
pub fn get_disks() -> anyhow::Result<IoIterator> { pub fn get_disks() -> anyhow::Result<IoIterator> {
let mut media_iter: io_iterator_t = 0; let mut media_iter: io_iterator_t = 0;

View File

@ -5,7 +5,7 @@ use std::mem;
use anyhow::{anyhow, bail}; use anyhow::{anyhow, bail};
use core_foundation::{ use core_foundation::{
base::{kCFAllocatorDefault, CFType, TCFType, ToVoid}, base::{CFType, TCFType, ToVoid, kCFAllocatorDefault},
dictionary::{ dictionary::{
CFDictionary, CFDictionaryGetTypeID, CFDictionaryRef, CFMutableDictionary, CFDictionary, CFDictionaryGetTypeID, CFDictionaryRef, CFMutableDictionary,
CFMutableDictionaryRef, CFMutableDictionaryRef,

View File

@ -5,9 +5,10 @@ use std::io::Error;
const MNT_NOWAIT: libc::c_int = 2; const MNT_NOWAIT: libc::c_int = 2;
extern "C" { // SAFETY: Bindings like this are inherently unsafe.
unsafe extern "C" {
fn getfsstat64(buf: *mut libc::statfs, bufsize: libc::c_int, flags: libc::c_int) fn getfsstat64(buf: *mut libc::statfs, bufsize: libc::c_int, flags: libc::c_int)
-> libc::c_int; -> libc::c_int;
} }
/// Returns all the mounts on the system at the moment. /// Returns all the mounts on the system at the moment.

View File

@ -57,7 +57,7 @@ fn partitions_iter() -> anyhow::Result<impl Iterator<Item = Partition>> {
let mounts = bindings::mounts()?; let mounts = bindings::mounts()?;
unsafe fn ptr_to_cow<'a>(ptr: *const i8) -> std::borrow::Cow<'a, str> { unsafe fn ptr_to_cow<'a>(ptr: *const i8) -> std::borrow::Cow<'a, str> {
CStr::from_ptr(ptr).to_string_lossy() unsafe { CStr::from_ptr(ptr).to_string_lossy() }
} }
Ok(mounts.into_iter().map(|stat| { Ok(mounts.into_iter().map(|stat| {

View File

@ -5,8 +5,8 @@ mod bindings;
use bindings::*; use bindings::*;
use itertools::Itertools; use itertools::Itertools;
use super::{keep_disk_entry, DiskHarvest}; use super::{DiskHarvest, keep_disk_entry};
use crate::collection::{disks::IoCounters, DataCollector}; use crate::collection::{DataCollector, disks::IoCounters};
/// Returns I/O stats. /// Returns I/O stats.
pub(crate) fn io_stats() -> anyhow::Result<Vec<IoCounters>> { pub(crate) fn io_stats() -> anyhow::Result<Vec<IoCounters>> {

View File

@ -11,13 +11,13 @@ use anyhow::bail;
use windows::Win32::{ use windows::Win32::{
Foundation::{self, CloseHandle, HANDLE}, Foundation::{self, CloseHandle, HANDLE},
Storage::FileSystem::{ Storage::FileSystem::{
CreateFileW, FindFirstVolumeW, FindNextVolumeW, FindVolumeClose, CreateFileW, FILE_FLAGS_AND_ATTRIBUTES, FILE_SHARE_READ, FILE_SHARE_WRITE,
GetVolumeNameForVolumeMountPointW, FILE_FLAGS_AND_ATTRIBUTES, FILE_SHARE_READ, FindFirstVolumeW, FindNextVolumeW, FindVolumeClose, GetVolumeNameForVolumeMountPointW,
FILE_SHARE_WRITE, OPEN_EXISTING, OPEN_EXISTING,
}, },
System::{ System::{
Ioctl::{DISK_PERFORMANCE, IOCTL_DISK_PERFORMANCE},
IO::DeviceIoControl, IO::DeviceIoControl,
Ioctl::{DISK_PERFORMANCE, IOCTL_DISK_PERFORMANCE},
}, },
}; };

View File

@ -65,11 +65,7 @@ pub fn zfs_io_stats() -> anyhow::Result<Vec<IoCounters>> {
.filter_map(|e| { .filter_map(|e| {
e.ok().and_then(|d| { e.ok().and_then(|d| {
let p = d.path(); let p = d.path();
if p.is_dir() { if p.is_dir() { Some(p) } else { None }
Some(p)
} else {
None
}
}) })
}) })
.collect(); .collect();

View File

@ -2,7 +2,7 @@ use std::{num::NonZeroU64, sync::OnceLock};
use hashbrown::HashMap; use hashbrown::HashMap;
use nvml_wrapper::{ use nvml_wrapper::{
enum_wrappers::device::TemperatureSensor, enums::device::UsedGpuMemory, error::NvmlError, Nvml, Nvml, enum_wrappers::device::TemperatureSensor, enums::device::UsedGpuMemory, error::NvmlError,
}; };
use crate::{ use crate::{

View File

@ -34,7 +34,7 @@ cfg_if! {
use std::{borrow::Cow, time::Duration}; use std::{borrow::Cow, time::Duration};
use super::{error::CollectionResult, DataCollector}; use super::{DataCollector, error::CollectionResult};
cfg_if! { cfg_if! {
if #[cfg(target_family = "windows")] { if #[cfg(target_family = "windows")] {

View File

@ -5,7 +5,7 @@ use std::{io, process::Command};
use hashbrown::HashMap; use hashbrown::HashMap;
use serde::{Deserialize, Deserializer}; use serde::{Deserialize, Deserializer};
use crate::collection::{deserialize_xo, processes::UnixProcessExt, Pid}; use crate::collection::{Pid, deserialize_xo, processes::UnixProcessExt};
#[derive(Deserialize, Debug, Default)] #[derive(Deserialize, Debug, Default)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]

View File

@ -13,8 +13,8 @@ use hashbrown::HashSet;
use process::*; use process::*;
use sysinfo::ProcessStatus; use sysinfo::ProcessStatus;
use super::{process_status_str, Pid, ProcessHarvest, UserTable}; use super::{Pid, ProcessHarvest, UserTable, process_status_str};
use crate::collection::{error::CollectionResult, DataCollector}; use crate::collection::{DataCollector, error::CollectionResult};
/// Maximum character length of a `/proc/<PID>/stat`` process name. /// 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. /// If it's equal or greater, then we instead refer to the command for the name.

View File

@ -3,10 +3,10 @@
use std::mem; use std::mem;
use anyhow::{bail, Result}; use anyhow::{Result, bail};
use libc::{ use libc::{
boolean_t, c_char, c_long, c_short, c_uchar, c_ushort, c_void, dev_t, gid_t, itimerval, pid_t, CTL_KERN, KERN_PROC, KERN_PROC_PID, MAXCOMLEN, boolean_t, c_char, c_long, c_short, c_uchar,
rusage, sigset_t, timeval, uid_t, xucred, CTL_KERN, KERN_PROC, KERN_PROC_PID, MAXCOMLEN, c_ushort, c_void, dev_t, gid_t, itimerval, pid_t, rusage, sigset_t, timeval, uid_t, xucred,
}; };
use mach2::vm_types::user_addr_t; use mach2::vm_types::user_addr_t;

View File

@ -5,8 +5,8 @@ use std::{io, time::Duration};
use hashbrown::HashMap; use hashbrown::HashMap;
use sysinfo::{ProcessStatus, System}; use sysinfo::{ProcessStatus, System};
use super::{process_status_str, ProcessHarvest}; use super::{ProcessHarvest, process_status_str};
use crate::collection::{error::CollectionResult, processes::UserTable, Pid}; use crate::collection::{Pid, error::CollectionResult, processes::UserTable};
pub(crate) trait UnixProcessExt { pub(crate) trait UnixProcessExt {
fn sysinfo_process_data( fn sysinfo_process_data(

View File

@ -2,8 +2,8 @@
use std::time::Duration; use std::time::Duration;
use super::{process_status_str, ProcessHarvest}; use super::{ProcessHarvest, process_status_str};
use crate::collection::{error::CollectionResult, DataCollector}; use crate::collection::{DataCollector, error::CollectionResult};
// TODO: There's a lot of shared code with this and the unix impl. // TODO: There's a lot of shared code with this and the unix impl.
pub fn sysinfo_process_data( pub fn sysinfo_process_data(

View File

@ -5,7 +5,7 @@ use std::sync::mpsc::Sender;
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers, MouseEvent, MouseEventKind}; use crossterm::event::{KeyCode, KeyEvent, KeyModifiers, MouseEvent, MouseEventKind};
use crate::{ use crate::{
app::{layout_manager::WidgetDirection, App}, app::{App, layout_manager::WidgetDirection},
collection::Data, collection::Data,
}; };

View File

@ -25,34 +25,32 @@ pub mod widgets;
use std::{ use std::{
boxed::Box, boxed::Box,
io::{stderr, stdout, Write}, io::{Write, stderr, stdout},
panic::{self, PanicHookInfo}, panic::{self, PanicHookInfo},
sync::{ sync::{
mpsc::{self, Receiver, Sender},
Arc, Arc,
mpsc::{self, Receiver, Sender},
}, },
thread::{self, JoinHandle}, thread::{self, JoinHandle},
time::{Duration, Instant}, time::{Duration, Instant},
}; };
use app::{layout_manager::UsedWidgets, App, AppConfigFields, DataFilters}; use app::{App, AppConfigFields, DataFilters, layout_manager::UsedWidgets};
use crossterm::{ use crossterm::{
cursor::{Hide, Show}, cursor::{Hide, Show},
event::{ event::{
poll, read, DisableBracketedPaste, DisableMouseCapture, EnableBracketedPaste, DisableBracketedPaste, DisableMouseCapture, EnableBracketedPaste, EnableMouseCapture,
EnableMouseCapture, Event, KeyEventKind, MouseEventKind, Event, KeyEventKind, MouseEventKind, poll, read,
}, },
execute, execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, terminal::{EnterAlternateScreen, LeaveAlternateScreen, disable_raw_mode, enable_raw_mode},
}; };
use event::{handle_key_event_or_break, handle_mouse_event, BottomEvent, CollectionThreadEvent}; use event::{BottomEvent, CollectionThreadEvent, handle_key_event_or_break, handle_mouse_event};
use options::{args, get_or_create_config, init_app}; use options::{args, get_or_create_config, init_app};
use tui::{backend::CrosstermBackend, Terminal}; use tui::{Terminal, backend::CrosstermBackend};
use utils::cancellation_token::CancellationToken;
use utils::conversion::*;
#[allow(unused_imports, reason = "this is needed if logging is enabled")] #[allow(unused_imports, reason = "this is needed if logging is enabled")]
use utils::logging::*; use utils::logging::*;
use utils::{cancellation_token::CancellationToken, conversion::*};
// Used for heap allocation debugging purposes. // Used for heap allocation debugging purposes.
// #[global_allocator] // #[global_allocator]
@ -323,13 +321,15 @@ pub fn start_bottom(enable_error_hook: &mut bool) -> anyhow::Result<()> {
let cancellation_token = cancellation_token.clone(); let cancellation_token = cancellation_token.clone();
let cleaning_sender = sender.clone(); let cleaning_sender = sender.clone();
let offset_wait = Duration::from_millis(app.app_config_fields.retention_ms + 60000); let offset_wait = Duration::from_millis(app.app_config_fields.retention_ms + 60000);
thread::spawn(move || loop { thread::spawn(move || {
if cancellation_token.sleep_with_cancellation(offset_wait) { loop {
break; if cancellation_token.sleep_with_cancellation(offset_wait) {
} break;
}
if cleaning_sender.send(BottomEvent::Clean).is_err() { if cleaning_sender.send(BottomEvent::Clean).is_err() {
break; break;
}
} }
}) })
}; };

View File

@ -16,8 +16,8 @@ use std::{
}; };
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use config::style::Styles;
pub use config::Config; pub use config::Config;
use config::style::Styles;
use data::TemperatureType; use data::TemperatureType;
pub(crate) use error::{OptionError, OptionResult}; pub(crate) use error::{OptionError, OptionResult};
use hashbrown::{HashMap, HashSet}; use hashbrown::{HashMap, HashSet};
@ -28,7 +28,7 @@ use starship_battery::Manager;
use self::{ use self::{
args::BottomArgs, args::BottomArgs,
config::{layout::Row, IgnoreList, StringOrNum}, config::{IgnoreList, StringOrNum, layout::Row},
}; };
use crate::{ use crate::{
app::{filter::Filter, layout_manager::*, *}, app::{filter::Filter, layout_manager::*, *},
@ -1009,7 +1009,7 @@ fn get_memory_legend_position(
mod test { mod test {
use clap::Parser; use clap::Parser;
use super::{get_time_interval, Config}; use super::{Config, get_time_interval};
use crate::{ use crate::{
app::App, app::App,
args::BottomArgs, args::BottomArgs,
@ -1234,10 +1234,10 @@ mod test {
fn test_get_config_path_macos() { fn test_get_config_path_macos() {
use std::path::PathBuf; use std::path::PathBuf;
use super::{get_config_path, DEFAULT_CONFIG_FILE_LOCATION}; use super::{DEFAULT_CONFIG_FILE_LOCATION, get_config_path};
// Case three: no previous config, no XDG var. // Case three: no previous config, no XDG var.
// SAFETY: this is the only test that does this // SAFETY: This is fine, this is just a test, and no other test affects env vars.
unsafe { unsafe {
std::env::remove_var("XDG_CONFIG_HOME"); std::env::remove_var("XDG_CONFIG_HOME");
} }
@ -1255,7 +1255,10 @@ mod test {
} }
// Case two: no previous config, XDG var exists. // Case two: no previous config, XDG var exists.
std::env::set_var("XDG_CONFIG_HOME", "/tmp"); // SAFETY: This is fine, this is just a test, and no other test affects env vars.
unsafe {
std::env::set_var("XDG_CONFIG_HOME", "/tmp");
}
let mut case_2 = PathBuf::new(); let mut case_2 = PathBuf::new();
case_2.push("/tmp"); case_2.push("/tmp");
case_2.push(DEFAULT_CONFIG_FILE_LOCATION); case_2.push(DEFAULT_CONFIG_FILE_LOCATION);

View File

@ -25,7 +25,7 @@ use utils::{opt, set_colour, set_colour_list, set_style};
use widgets::WidgetStyle; use widgets::WidgetStyle;
use super::Config; use super::Config;
use crate::options::{args::BottomArgs, OptionError, OptionResult}; use crate::options::{OptionError, OptionResult, args::BottomArgs};
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(feature = "generate_schema", derive(schemars::JsonSchema))] #[cfg_attr(feature = "generate_schema", derive(schemars::JsonSchema))]

View File

@ -4,7 +4,7 @@ use tui::{
}; };
use super::{color, hex}; use super::{color, hex};
use crate::options::config::style::{utils::convert_hex_to_color, Styles}; use crate::options::config::style::{Styles, utils::convert_hex_to_color};
impl Styles { impl Styles {
pub(crate) fn gruvbox_palette() -> Self { pub(crate) fn gruvbox_palette() -> Self {

View File

@ -4,7 +4,7 @@ use tui::{
}; };
use super::{color, hex}; use super::{color, hex};
use crate::options::config::style::{utils::convert_hex_to_color, Styles}; use crate::options::config::style::{Styles, utils::convert_hex_to_color};
impl Styles { impl Styles {
pub(crate) fn nord_palette() -> Self { pub(crate) fn nord_palette() -> Self {

View File

@ -135,8 +135,8 @@ macro_rules! set_style {
match &style { match &style {
TextStyleConfig::Colour(colour) => { TextStyleConfig::Colour(colour) => {
$palette_field = $palette_field.fg( $palette_field = $palette_field.fg(
crate::options::config::style::utils::str_to_colour(&colour.0) crate::options::config::style::utils::str_to_colour(&colour.0).map_err(
.map_err(|err| match stringify!($config_location).split_once(".") { |err| match stringify!($config_location).split_once(".") {
Some((_, loc)) => crate::options::OptionError::config(format!( Some((_, loc)) => crate::options::OptionError::config(format!(
"Please update 'styles.{loc}.{}' in your config file. {err}", "Please update 'styles.{loc}.{}' in your config file. {err}",
stringify!($field) stringify!($field)
@ -145,55 +145,71 @@ macro_rules! set_style {
"Please update 'styles.{}' in your config file. {err}", "Please update 'styles.{}' in your config file. {err}",
stringify!($field) stringify!($field)
)), )),
})? },
)?,
); );
} }
TextStyleConfig::TextStyle {color, bg_color, bold, italics} => { TextStyleConfig::TextStyle {
color,
bg_color,
bold,
italics,
} => {
if let Some(fg) = &color { if let Some(fg) = &color {
$palette_field = $palette_field.fg( $palette_field = $palette_field
crate::options::config::style::utils::str_to_colour(&fg.0) .fg(crate::options::config::style::utils::str_to_colour(
.map_err(|err| match stringify!($config_location).split_once(".") { &fg.0,
Some((_, loc)) => crate::options::OptionError::config(format!( )
"Please update 'styles.{loc}.{}' in your config file. {err}", .map_err(|err| {
stringify!($field) match stringify!($config_location).split_once(".") {
)), Some((_, loc)) => crate::options::OptionError::config(format!(
None => crate::options::OptionError::config(format!( "Please update 'styles.{loc}.{}' in your config file. {err}",
"Please update 'styles.{}' in your config file. {err}", stringify!($field)
stringify!($field) )),
)), None => crate::options::OptionError::config(format!(
})? "Please update 'styles.{}' in your config file. {err}",
); stringify!($field)
)),
}
})?);
} }
if let Some(bg) = &bg_color { if let Some(bg) = &bg_color {
$palette_field = $palette_field.bg( $palette_field = $palette_field
crate::options::config::style::utils::str_to_colour(&bg.0) .bg(crate::options::config::style::utils::str_to_colour(
.map_err(|err| match stringify!($config_location).split_once(".") { &bg.0,
Some((_, loc)) => crate::options::OptionError::config(format!( )
"Please update 'styles.{loc}.{}' in your config file. {err}", .map_err(|err| {
stringify!($field) match stringify!($config_location).split_once(".") {
)), Some((_, loc)) => crate::options::OptionError::config(format!(
None => crate::options::OptionError::config(format!( "Please update 'styles.{loc}.{}' in your config file. {err}",
"Please update 'styles.{}' in your config file. {err}", stringify!($field)
stringify!($field) )),
)), None => crate::options::OptionError::config(format!(
})? "Please update 'styles.{}' in your config file. {err}",
); stringify!($field)
)),
}
})?);
} }
if let Some(bold) = &bold { if let Some(bold) = &bold {
if *bold { if *bold {
$palette_field = $palette_field.add_modifier(tui::style::Modifier::BOLD); $palette_field =
$palette_field.add_modifier(tui::style::Modifier::BOLD);
} else { } else {
$palette_field = $palette_field.remove_modifier(tui::style::Modifier::BOLD); $palette_field =
$palette_field.remove_modifier(tui::style::Modifier::BOLD);
} }
} }
if let Some(italics) = &italics { if let Some(italics) = &italics {
if *italics { if *italics {
$palette_field = $palette_field.add_modifier(tui::style::Modifier::ITALIC); $palette_field =
$palette_field.add_modifier(tui::style::Modifier::ITALIC);
} else { } else {
$palette_field = $palette_field.remove_modifier(tui::style::Modifier::ITALIC); $palette_field =
$palette_field.remove_modifier(tui::style::Modifier::ITALIC);
} }
} }
} }

View File

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use super::{borders::WidgetBorderType, ColorStr, TextStyleConfig}; use super::{ColorStr, TextStyleConfig, borders::WidgetBorderType};
/// General styling for generic widgets. /// General styling for generic widgets.
#[derive(Clone, Debug, Default, Deserialize, Serialize)] #[derive(Clone, Debug, Default, Deserialize, Serialize)]

View File

@ -64,20 +64,12 @@ clamp_num_impl!(u8, u16, u32, u64, usize);
/// Checked log2. /// Checked log2.
pub fn saturating_log2(value: f64) -> f64 { pub fn saturating_log2(value: f64) -> f64 {
if value > 0.0 { if value > 0.0 { value.log2() } else { 0.0 }
value.log2()
} else {
0.0
}
} }
/// Checked log10. /// Checked log10.
pub fn saturating_log10(value: f64) -> f64 { pub fn saturating_log10(value: f64) -> f64 {
if value > 0.0 { if value > 0.0 { value.log10() } else { 0.0 }
value.log10()
} else {
0.0
}
} }
#[cfg(test)] #[cfg(test)]

View File

@ -6,11 +6,11 @@ use tui::widgets::Row;
use crate::{ use crate::{
app::AppConfigFields, app::AppConfigFields,
canvas::{ canvas::{
Painter,
components::data_table::{ components::data_table::{
Column, ColumnHeader, DataTable, DataTableColumn, DataTableProps, DataTableStyling, Column, ColumnHeader, DataTable, DataTableColumn, DataTableProps, DataTableStyling,
DataToCell, DataToCell,
}, },
Painter,
}, },
collection::cpu::{CpuData, CpuDataType}, collection::cpu::{CpuData, CpuDataType},
options::config::{cpu::CpuDefault, style::Styles}, options::config::{cpu::CpuDefault, style::Styles},

View File

@ -3,7 +3,7 @@ use std::{borrow::Cow, cmp::max, num::NonZeroU16};
use serde::Deserialize; use serde::Deserialize;
use crate::{ use crate::{
app::{data::StoredData, AppConfigFields}, app::{AppConfigFields, data::StoredData},
canvas::components::data_table::{ canvas::components::data_table::{
ColumnHeader, DataTableColumn, DataTableProps, DataTableStyling, DataToCell, SortColumn, ColumnHeader, DataTableColumn, DataTableProps, DataTableStyling, DataToCell, SortColumn,
SortDataTable, SortDataTableProps, SortOrder, SortsRow, SortDataTable, SortDataTableProps, SortOrder, SortsRow,

View File

@ -10,13 +10,13 @@ use indexmap::IndexSet;
use itertools::Itertools; use itertools::Itertools;
pub use process_columns::*; pub use process_columns::*;
pub use process_data::*; pub use process_data::*;
use query::{parse_query, ProcessQuery}; use query::{ProcessQuery, parse_query};
use sort_table::SortTableColumn; use sort_table::SortTableColumn;
use crate::{ use crate::{
app::{ app::{
data::{ProcessData, StoredData},
AppConfigFields, AppSearchState, AppConfigFields, AppSearchState,
data::{ProcessData, StoredData},
}, },
canvas::components::data_table::{ canvas::components::data_table::{
Column, ColumnHeader, ColumnWidthBounds, DataTable, DataTableColumn, DataTableProps, Column, ColumnHeader, ColumnWidthBounds, DataTable, DataTableColumn, DataTableProps,

View File

@ -1,6 +1,6 @@
use std::{ use std::{
borrow::Cow, borrow::Cow,
cmp::{max, Ordering}, cmp::{Ordering, max},
fmt::Display, fmt::Display,
num::NonZeroU16, num::NonZeroU16,
time::Duration, time::Duration,
@ -12,12 +12,12 @@ use tui::widgets::Row;
use super::process_columns::ProcColumn; use super::process_columns::ProcColumn;
use crate::{ use crate::{
canvas::{ canvas::{
components::data_table::{DataTableColumn, DataToCell},
Painter, Painter,
components::data_table::{DataTableColumn, DataToCell},
}, },
collection::processes::{Pid, ProcessHarvest}, collection::processes::{Pid, ProcessHarvest},
dec_bytes_per_second_string, dec_bytes_per_second_string,
utils::data_units::{get_binary_bytes, get_decimal_bytes, GIBI_LIMIT, GIGA_LIMIT}, utils::data_units::{GIBI_LIMIT, GIGA_LIMIT, get_binary_bytes, get_decimal_bytes},
}; };
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
@ -391,9 +391,8 @@ impl DataToCell<ProcColumn> for ProcWidgetData {
mod test { mod test {
use std::time::Duration; use std::time::Duration;
use crate::utils::data_units::*;
use super::*; use super::*;
use crate::utils::data_units::*;
#[test] #[test]
fn test_format_time() { fn test_format_time() {

View File

@ -329,7 +329,7 @@ pub(crate) fn parse_query(
or: None, or: None,
regex_prefix: Some((prefix_type, StringQuery::Value(content))), regex_prefix: Some((prefix_type, StringQuery::Value(content))),
compare_prefix: None, compare_prefix: None,
}) });
} }
PrefixType::Pid | PrefixType::State | PrefixType::User => { PrefixType::Pid | PrefixType::State | PrefixType::User => {
// We have to check if someone put an "="... // We have to check if someone put an "="...

View File

@ -1,7 +1,7 @@
use std::{borrow::Cow, cmp::max, num::NonZeroU16}; use std::{borrow::Cow, cmp::max, num::NonZeroU16};
use crate::{ use crate::{
app::{data::TypedTemperature, AppConfigFields}, app::{AppConfigFields, data::TypedTemperature},
canvas::components::data_table::{ canvas::components::data_table::{
ColumnHeader, DataTableColumn, DataTableProps, DataTableStyling, DataToCell, SortColumn, ColumnHeader, DataTableColumn, DataTableProps, DataTableStyling, DataToCell, SortColumn,
SortDataTable, SortDataTableProps, SortOrder, SortsRow, SortDataTable, SortDataTableProps, SortOrder, SortsRow,

View File

@ -2,7 +2,7 @@ use std::{env, ffi::OsString, path::Path, process::Command};
use hashbrown::HashMap; use hashbrown::HashMap;
#[cfg(all(target_arch = "x86_64", target_os = "linux"))] #[cfg(all(target_arch = "x86_64", target_os = "linux"))]
use portable_pty::{native_pty_system, Child, CommandBuilder, MasterPty, PtySize}; use portable_pty::{Child, CommandBuilder, MasterPty, PtySize, native_pty_system};
pub fn abs_path(path: &str) -> OsString { pub fn abs_path(path: &str) -> OsString {
let path = Path::new(path); let path = Path::new(path);