summaryrefslogtreecommitdiffstats
path: root/src/app
diff options
context:
space:
mode:
authorClementTsang <clementjhtsang@gmail.com>2019-12-07 03:01:35 -0500
committerClementTsang <clementjhtsang@gmail.com>2019-12-07 03:01:35 -0500
commit9913cc9fda2dd5399ac4ea39e1d13fc2560fa72c (patch)
treea310b5b1859d5c751dad44d1f5fd3899c09e1adb /src/app
parentb9b7d61a9921cc3d0cf58aab073e7408a8db4c95 (diff)
Update dependencies
Diffstat (limited to 'src/app')
-rw-r--r--src/app/data_collection/disks.rs62
-rw-r--r--src/app/data_collection/mem.rs2
-rw-r--r--src/app/data_collection/temperature.rs34
3 files changed, 46 insertions, 52 deletions
diff --git a/src/app/data_collection/disks.rs b/src/app/data_collection/disks.rs
index 1d444bf6..f6ce7906 100644
--- a/src/app/data_collection/disks.rs
+++ b/src/app/data_collection/disks.rs
@@ -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
}
});
diff --git a/src/app/data_collection/mem.rs b/src/app/data_collection/mem.rs
index f4a8be1a..5423ae4a 100644
--- a/src/app/data_collection/mem.rs
+++ b/src/app/data_collection/mem.rs
@@ -1,4 +1,4 @@
-use heim_common::units::information;
+use heim::units::information;
use std::time::Instant;
#[derive(Clone)]
diff --git a/src/app/data_collection/temperature.rs b/src/app/data_collection/temperature.rs
index 274e4175..7a455aff 100644
--- a/src/app/data_collection/temperature.rs
+++ b/src/app/data_collection/temperature.rs
@@ -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
}
});