[skip travis] Changed rustfmt, formatting.

This commit is contained in:
ClementTsang 2019-09-15 01:32:08 -04:00
parent e593149ef9
commit 05d4e82153
6 changed files with 40 additions and 10 deletions

View File

@ -1,4 +1,4 @@
max_width = 200
max_width = 175
reorder_imports = true
control_brace_style = "ClosingNextLine"
fn_args_layout = "Compressed"

View File

@ -24,5 +24,8 @@ pub fn get_cpu_data_list(sys : &System) -> Result<CPUPackage, heim::Error> {
})
}
Ok(CPUPackage { cpu_vec, instant : Instant::now() })
Ok(CPUPackage {
cpu_vec,
instant : Instant::now(),
})
}

View File

@ -48,7 +48,10 @@ pub async fn get_io_usage_list(get_physical : bool) -> Result<IOPackage, heim::E
}
}
Ok(IOPackage { io_list, instant : Instant::now() })
Ok(IOPackage {
io_list,
instant : Instant::now(),
})
}
pub async fn get_disk_usage_list() -> Result<Vec<DiskData>, heim::Error> {
@ -65,7 +68,13 @@ pub async fn get_disk_usage_list() -> Result<Vec<DiskData>, heim::Error> {
used_space : usage.used().get::<heim_common::units::information::megabyte>(),
total_space : usage.total().get::<heim_common::units::information::megabyte>(),
mount_point : Box::from(partition.mount_point().to_str().unwrap_or("Name Unavailable")),
name : Box::from(partition.device().unwrap_or_else(|| std::ffi::OsStr::new("Name Unavailable")).to_str().unwrap_or("Name Unavailable")),
name : Box::from(
partition
.device()
.unwrap_or_else(|| std::ffi::OsStr::new("Name Unavailable"))
.to_str()
.unwrap_or("Name Unavailable"),
),
});
}
}

View File

@ -173,7 +173,10 @@ pub async fn get_sorted_processes_list(prev_idle : &mut f64, prev_non_idle : &mu
if cfg!(target_os = "linux") {
// Linux specific - this is a massive pain... ugh.
let ps_result = Command::new("ps").args(&["-axo", "pid:10,comm:50,%mem:5", "--noheader"]).output().expect("Failed to execute.");
let ps_result = Command::new("ps")
.args(&["-axo", "pid:10,comm:50,%mem:5", "--noheader"])
.output()
.expect("Failed to execute.");
let ps_stdout = String::from_utf8_lossy(&ps_result.stdout);
let split_string = ps_stdout.split('\n');
let cpu_usage = vangelis_cpu_usage_calculation(prev_idle, prev_non_idle).unwrap(); // TODO: FIX THIS ERROR CHECKING

View File

@ -30,9 +30,15 @@ pub struct CanvasData {
pub fn draw_data<B : tui::backend::Backend>(terminal : &mut Terminal<B>, app_data : &app::App, canvas_data : &CanvasData) -> error::Result<()> {
let border_style : Style = Style::default().fg(BORDER_STYLE_COLOUR);
let temperature_rows = canvas_data.temp_sensor_data.iter().map(|sensor| Row::StyledData(sensor.iter(), Style::default().fg(TEXT_COLOUR)));
let temperature_rows = canvas_data
.temp_sensor_data
.iter()
.map(|sensor| Row::StyledData(sensor.iter(), Style::default().fg(TEXT_COLOUR)));
let disk_rows = canvas_data.disk_data.iter().map(|disk| Row::StyledData(disk.iter(), Style::default().fg(TEXT_COLOUR)));
let process_rows = canvas_data.process_data.iter().map(|process| Row::StyledData(process.iter(), Style::default().fg(TEXT_COLOUR)));
let process_rows = canvas_data
.process_data
.iter()
.map(|process| Row::StyledData(process.iter(), Style::default().fg(TEXT_COLOUR)));
terminal.draw(|mut f| {
debug!("Drawing!");
@ -146,7 +152,13 @@ pub fn draw_data<B : tui::backend::Backend>(terminal : &mut Terminal<B>, app_dat
Table::new(["Disk", "Mount", "Used", "Total", "Free"].iter(), disk_rows)
.block(Block::default().title("Disk Usage").borders(Borders::ALL).border_style(border_style))
.header_style(Style::default().fg(Color::LightBlue).modifier(Modifier::BOLD))
.widths(&[(width * 0.25) as u16, (width * 0.2) as u16, (width * 0.15) as u16, (width * 0.15) as u16, (width * 0.15) as u16])
.widths(&[
(width * 0.25) as u16,
(width * 0.2) as u16,
(width * 0.15) as u16,
(width * 0.15) as u16,
(width * 0.15) as u16,
])
.render(&mut f, middle_divided_chunk_2[1]);
}

View File

@ -302,8 +302,11 @@ fn update_cpu_data_points(show_avg_cpu : bool, app_data : &data_collection::Data
for (i, data) in cpu_collection.iter().enumerate() {
cpu_data_vector.push((
// + 1 to skip total CPU if show_avg_cpu is false
format!("{:4}: ", &*(app_data.list_of_cpu_packages.last().unwrap().cpu_vec[i + if show_avg_cpu { 0 } else { 1 }].cpu_name)).to_uppercase()
+ &format!("{:3}%", (data.last().unwrap_or(&(0_f64, 0_f64)).1.round() as u64)),
format!(
"{:4}: ",
&*(app_data.list_of_cpu_packages.last().unwrap().cpu_vec[i + if show_avg_cpu { 0 } else { 1 }].cpu_name)
)
.to_uppercase() + &format!("{:3}%", (data.last().unwrap_or(&(0_f64, 0_f64)).1.round() as u64)),
data.clone(),
))
}