Optimized imports as per clion

This commit is contained in:
ClementTsang 2020-02-28 22:24:24 -05:00
parent d922f85b95
commit bbdd7786ce
13 changed files with 91 additions and 74 deletions

View file

@ -1,16 +1,17 @@
pub mod data_harvester;
use data_harvester::{processes, temperature};
use std::time::Instant;
pub mod data_farmer;
use data_farmer::*;
use crate::{canvas, constants, utils::error::Result};
mod process_killer;
use unicode_segmentation::GraphemeCursor;
use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};
use data_farmer::*;
use data_harvester::{processes, temperature};
use crate::{canvas, constants, utils::error::Result};
pub mod data_harvester;
pub mod data_farmer;
mod process_killer;
const MAX_SEARCH_LENGTH: usize = 200;
#[derive(Debug, Clone, Copy)]

View file

@ -1,4 +1,3 @@
use crate::data_harvester::{cpu, disks, mem, network, processes, temperature, Data};
/// In charge of cleaning, processing, and managing data. I couldn't think of
/// a better name for the file. Since I called data collection "harvesting",
/// then this is the farmer I guess.
@ -16,6 +15,8 @@ use crate::data_harvester::{cpu, disks, mem, network, processes, temperature, Da
use std::time::Instant;
use std::vec::Vec;
use crate::data_harvester::{cpu, Data, disks, mem, network, processes, temperature};
pub type TimeOffset = f64;
pub type Value = f64;
pub type JoinedDataPoints = (Value, Vec<(TimeOffset, Value)>);

View file

@ -1,6 +1,7 @@
//! This is the main file to house data collection functions.
use std::{collections::HashMap, time::Instant};
use sysinfo::{System, SystemExt};
pub mod cpu;

View file

@ -1,7 +1,8 @@
use std::time::Instant;
use futures::StreamExt;
use heim::net;
use heim::units::information::byte;
use std::time::Instant;
use sysinfo::{NetworkExt, System, SystemExt};
#[derive(Default, Clone, Debug)]

View file

@ -1,10 +1,13 @@
use crate::utils::error;
use std::{
collections::{hash_map::RandomState, HashMap},
process::Command,
time::Instant,
collections::{hash_map::RandomState, HashMap},
process::Command,
time::Instant,
};
use sysinfo::{ProcessExt, ProcessorExt, System, SystemExt};
use crate::utils::error;
#[derive(Clone)]
pub enum ProcessSorting {
CPU,

View file

@ -1,6 +1,7 @@
use std::cmp::Ordering;
use futures::StreamExt;
use heim::units::thermodynamic_temperature;
use std::cmp::Ordering;
use sysinfo::{ComponentExt, System, SystemExt};
#[derive(Default, Debug, Clone)]

View file

@ -1,17 +1,18 @@
/// This file is meant to house (OS specific) implementations on how to kill processes.
use crate::utils::error::BottomError;
use std::process::Command;
// Copied from SO: https://stackoverflow.com/a/55231715
#[cfg(target_os = "windows")]
use winapi::{
shared::{minwindef::DWORD, ntdef::HANDLE},
um::{
processthreadsapi::{OpenProcess, TerminateProcess},
winnt::{PROCESS_QUERY_INFORMATION, PROCESS_TERMINATE},
shared::{minwindef::DWORD, ntdef::HANDLE},
um::{
processthreadsapi::{OpenProcess, TerminateProcess},
winnt::{PROCESS_QUERY_INFORMATION, PROCESS_TERMINATE},
},
};
/// This file is meant to house (OS specific) implementations on how to kill processes.
use crate::utils::error::BottomError;
#[cfg(target_os = "windows")]
struct Process(HANDLE);

View file

@ -1,28 +1,30 @@
use crate::{
app::{self, data_harvester::processes::ProcessHarvest, WidgetPosition},
constants::*,
data_conversion::{ConvertedCpuData, ConvertedProcessData},
utils::error,
};
use std::cmp::max;
use std::collections::HashMap;
use tui::{
backend,
layout::{Alignment, Constraint, Direction, Layout, Rect},
style::{Color, Style},
terminal::Frame,
widgets::{Axis, Block, Borders, Chart, Dataset, Marker, Paragraph, Row, Table, Text, Widget},
Terminal,
backend,
layout::{Alignment, Constraint, Direction, Layout, Rect},
style::{Color, Style},
Terminal,
terminal::Frame,
widgets::{Axis, Block, Borders, Chart, Dataset, Marker, Paragraph, Row, Table, Text, Widget},
};
use unicode_segmentation::UnicodeSegmentation;
use unicode_width::UnicodeWidthStr;
mod canvas_colours;
use canvas_colours::*;
mod drawing_utils;
use drawing_utils::*;
use crate::{
app::{self, data_harvester::processes::ProcessHarvest, WidgetPosition},
constants::*,
data_conversion::{ConvertedCpuData, ConvertedProcessData},
utils::error,
};
mod canvas_colours;
mod drawing_utils;
// Headers
const CPU_LEGEND_HEADER: [&str; 2] = ["CPU", "Use%"];
const CPU_SELECT_LEGEND_HEADER: [&str; 2] = ["CPU", "Show (Space)"];

View file

@ -1,9 +1,11 @@
mod colour_utils;
use colour_utils::*;
use tui::style::{Color, Modifier, Style};
use colour_utils::*;
use crate::{constants::*, utils::error};
mod colour_utils;
pub struct CanvasColours {
pub currently_selected_text_colour: Color,
pub currently_selected_bg_colour: Color,

View file

@ -1,7 +1,9 @@
use crate::utils::{error, gen_util::*};
use std::collections::HashMap;
use tui::style::{Color, Style};
use crate::utils::{error, gen_util::*};
const GOLDEN_RATIO: f32 = 0.618_034; // Approx, good enough for use (also Clippy gets mad if it's too long)
pub const STANDARD_FIRST_COLOUR: Color = Color::LightMagenta;
pub const STANDARD_SECOND_COLOUR: Color = Color::LightYellow;

View file

@ -1,18 +1,20 @@
//! This mainly concerns converting collected data into things that the canvas
//! can actually handle.
use crate::{
app::{
data_farmer,
data_harvester::{self, processes::ProcessHarvest},
App,
},
constants,
utils::gen_util::{get_exact_byte_values, get_simple_byte_values},
};
use constants::*;
use std::collections::HashMap;
use constants::*;
use crate::{
app::{
App,
data_farmer,
data_harvester::{self, processes::ProcessHarvest},
},
constants,
utils::gen_util::{get_exact_byte_values, get_simple_byte_values},
};
#[derive(Default, Debug)]
pub struct ConvertedNetworkData {
pub rx: Vec<(f64, f64)>,

View file

@ -1,26 +1,13 @@
#![warn(rust_2018_idioms)]
#[macro_use]
extern crate log;
#[macro_use]
extern crate clap;
#[macro_use]
extern crate futures;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate futures;
use serde::Deserialize;
use crossterm::{
event::{
poll, read, DisableMouseCapture, EnableMouseCapture, Event as CEvent, KeyCode, KeyEvent,
KeyModifiers, MouseEvent,
},
execute,
style::Print,
terminal::LeaveAlternateScreen,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen},
};
extern crate log;
use std::{
boxed::Box,
@ -30,8 +17,28 @@ use std::{
thread,
time::{Duration, Instant},
};
use crossterm::{
event::{
DisableMouseCapture, EnableMouseCapture, Event as CEvent, KeyCode, KeyEvent, KeyModifiers, MouseEvent,
poll, read,
},
execute,
style::Print,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen},
terminal::LeaveAlternateScreen,
};
use serde::Deserialize;
use tui::{backend::CrosstermBackend, Terminal};
use app::{
App,
data_harvester::{self, processes::ProcessSorting},
};
use constants::*;
use data_conversion::*;
use utils::error::{self, BottomError};
pub mod app;
mod utils {
pub mod error;
@ -42,14 +49,6 @@ mod canvas;
mod constants;
mod data_conversion;
use app::{
data_harvester::{self, processes::ProcessSorting},
App,
};
use constants::*;
use data_conversion::*;
use utils::error::{self, BottomError};
enum Event<I, J> {
KeyInput(I),
MouseInput(J),

View file

@ -1,6 +1,7 @@
use std::process::Command;
use assert_cmd::prelude::*;
use predicates::prelude::*;
use std::process::Command;
// These tests are mostly here just to ensure that invalid results will be caught when passing arguments...