Update dependencies

This commit is contained in:
ClementTsang 2019-12-07 03:01:35 -05:00
parent b9b7d61a99
commit 9913cc9fda
4 changed files with 53 additions and 61 deletions

View file

@ -15,25 +15,23 @@ name = "btm"
path = "src/main.rs"
[dependencies]
chrono = "0.4.9"
chrono = "0.4.10"
clap = "2.33.0"
crossterm = "0.13"
failure = "0.1.5"
futures-preview = "0.3.0-alpha.18"
failure = "0.1.6"
fern = "0.5"
futures-timer = "0.3"
futures-util = "0.2.1"
heim = "0.0.7"
heim-common = "0.0.7"
futures-preview = "0.3.0-alpha.18"
heim = "0.0.8"
log = "0.4"
rayon = "1.2"
regex = "1.3.1"
sysinfo = "0.9.4"
tokio = "0.2.0-alpha.4"
sysinfo = "0.10.0"
tokio = "0.2.4"
winapi = "0.3.8"
[dependencies.tui]
git = "https://github.com/ClementTsang/tui-rs"
# git = "https://github.com/ClementTsang/tui-rs"
# path = "../tui-rs"
version = "0.7"
default-features = false

View file

@ -1,30 +1,31 @@
use heim_common::prelude::StreamExt;
use futures::StreamExt;
use heim::units::information;
use std::time::Instant;
#[derive(Clone, Default)]
pub struct DiskData {
pub name : Box<str>,
pub mount_point : Box<str>,
pub free_space : u64,
pub used_space : u64,
pub total_space : u64,
pub name: Box<str>,
pub mount_point: Box<str>,
pub free_space: u64,
pub used_space: u64,
pub total_space: u64,
}
#[derive(Clone, Debug)]
pub struct IOData {
pub mount_point : Box<str>,
pub read_bytes : u64,
pub write_bytes : u64,
pub mount_point: Box<str>,
pub read_bytes: u64,
pub write_bytes: u64,
}
#[derive(Clone)]
pub struct IOPackage {
pub io_hash : std::collections::HashMap<String, IOData>,
pub instant : Instant,
pub io_hash: std::collections::HashMap<String, IOData>,
pub instant: Instant,
}
pub async fn get_io_usage_list(get_physical : bool) -> crate::utils::error::Result<IOPackage> {
let mut io_hash : std::collections::HashMap<String, IOData> = std::collections::HashMap::new();
pub async fn get_io_usage_list(get_physical: bool) -> crate::utils::error::Result<IOPackage> {
let mut io_hash: std::collections::HashMap<String, IOData> = std::collections::HashMap::new();
if get_physical {
let mut physical_counter_stream = heim::disk::io_counters_physical();
while let Some(io) = physical_counter_stream.next().await {
@ -33,14 +34,13 @@ pub async fn get_io_usage_list(get_physical : bool) -> crate::utils::error::Resu
io_hash.insert(
mount_point.to_string(),
IOData {
mount_point : Box::from(mount_point),
read_bytes : io.read_bytes().get::<heim_common::units::information::megabyte>(),
write_bytes : io.write_bytes().get::<heim_common::units::information::megabyte>(),
mount_point: Box::from(mount_point),
read_bytes: io.read_bytes().get::<information::megabyte>(),
write_bytes: io.write_bytes().get::<information::megabyte>(),
},
);
}
}
else {
} else {
let mut counter_stream = heim::disk::io_counters();
while let Some(io) = counter_stream.next().await {
let io = io?;
@ -48,9 +48,9 @@ pub async fn get_io_usage_list(get_physical : bool) -> crate::utils::error::Resu
io_hash.insert(
mount_point.to_string(),
IOData {
mount_point : Box::from(mount_point),
read_bytes : io.read_bytes().get::<heim_common::units::information::byte>(),
write_bytes : io.write_bytes().get::<heim_common::units::information::byte>(),
mount_point: Box::from(mount_point),
read_bytes: io.read_bytes().get::<information::byte>(),
write_bytes: io.write_bytes().get::<information::byte>(),
},
);
}
@ -58,12 +58,12 @@ pub async fn get_io_usage_list(get_physical : bool) -> crate::utils::error::Resu
Ok(IOPackage {
io_hash,
instant : Instant::now(),
instant: Instant::now(),
})
}
pub async fn get_disk_usage_list() -> crate::utils::error::Result<Vec<DiskData>> {
let mut vec_disks : Vec<DiskData> = Vec::new();
let mut vec_disks: Vec<DiskData> = Vec::new();
let mut partitions_stream = heim::disk::partitions_physical();
while let Some(part) = partitions_stream.next().await {
@ -72,11 +72,11 @@ pub async fn get_disk_usage_list() -> crate::utils::error::Result<Vec<DiskData>>
let usage = heim::disk::usage(partition.mount_point().to_path_buf()).await?;
vec_disks.push(DiskData {
free_space : usage.free().get::<heim_common::units::information::megabyte>(),
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(
free_space: usage.free().get::<information::megabyte>(),
used_space: usage.used().get::<information::megabyte>(),
total_space: usage.total().get::<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"))
@ -90,11 +90,9 @@ pub async fn get_disk_usage_list() -> crate::utils::error::Result<Vec<DiskData>>
vec_disks.sort_by(|a, b| {
if a.name < b.name {
std::cmp::Ordering::Less
}
else if a.name > b.name {
} else if a.name > b.name {
std::cmp::Ordering::Greater
}
else {
} else {
std::cmp::Ordering::Equal
}
});

View file

@ -1,4 +1,4 @@
use heim_common::units::information;
use heim::units::information;
use std::time::Instant;
#[derive(Clone)]

View file

@ -1,10 +1,11 @@
use heim_common::{prelude::StreamExt, units::thermodynamic_temperature};
use futures::StreamExt;
use heim::units::thermodynamic_temperature;
use sysinfo::{ComponentExt, System, SystemExt};
#[derive(Clone)]
pub struct TempData {
pub component_name : Box<str>,
pub temperature : f32,
pub component_name: Box<str>,
pub temperature: f32,
}
#[derive(Clone, Debug)]
@ -20,16 +21,16 @@ impl Default for TemperatureType {
}
}
pub async fn get_temperature_data(sys : &System, temp_type : &TemperatureType) -> crate::utils::error::Result<Vec<TempData>> {
let mut temperature_vec : Vec<TempData> = Vec::new();
pub async fn get_temperature_data(sys: &System, temp_type: &TemperatureType) -> crate::utils::error::Result<Vec<TempData>> {
let mut temperature_vec: Vec<TempData> = Vec::new();
if cfg!(target_os = "linux") {
let mut sensor_data = heim::sensors::temperatures();
while let Some(sensor) = sensor_data.next().await {
if let Ok(sensor) = sensor {
temperature_vec.push(TempData {
component_name : Box::from(sensor.unit()),
temperature : match temp_type {
component_name: Box::from(sensor.unit()),
temperature: match temp_type {
TemperatureType::Celsius => sensor.current().get::<thermodynamic_temperature::degree_celsius>(),
TemperatureType::Kelvin => sensor.current().get::<thermodynamic_temperature::kelvin>(),
TemperatureType::Fahrenheit => sensor.current().get::<thermodynamic_temperature::degree_fahrenheit>(),
@ -37,13 +38,12 @@ pub async fn get_temperature_data(sys : &System, temp_type : &TemperatureType) -
});
}
}
}
else if cfg!(target_os = "windows") {
} else if cfg!(target_os = "windows") {
let sensor_data = sys.get_components_list();
for component in sensor_data {
temperature_vec.push(TempData {
component_name : Box::from(component.get_label()),
temperature : match temp_type {
component_name: Box::from(component.get_label()),
temperature: match temp_type {
TemperatureType::Celsius => component.get_temperature(),
TemperatureType::Kelvin => component.get_temperature() + 273.15,
TemperatureType::Fahrenheit => (component.get_temperature() * (9.0 / 5.0)) + 32.0,
@ -58,11 +58,9 @@ pub async fn get_temperature_data(sys : &System, temp_type : &TemperatureType) -
temperature_vec.sort_by(|a, b| {
if a.temperature > b.temperature {
std::cmp::Ordering::Less
}
else if a.temperature < b.temperature {
} else if a.temperature < b.temperature {
std::cmp::Ordering::Greater
}
else {
} else {
std::cmp::Ordering::Equal
}
});
@ -70,11 +68,9 @@ pub async fn get_temperature_data(sys : &System, temp_type : &TemperatureType) -
temperature_vec.sort_by(|a, b| {
if a.component_name > b.component_name {
std::cmp::Ordering::Greater
}
else if a.component_name < b.component_name {
} else if a.component_name < b.component_name {
std::cmp::Ordering::Less
}
else {
} else {
std::cmp::Ordering::Equal
}
});