summaryrefslogtreecommitdiffstats
path: root/src/app/data_harvester
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/data_harvester')
-rw-r--r--src/app/data_harvester/disks.rs18
-rw-r--r--src/app/data_harvester/network.rs19
-rw-r--r--src/app/data_harvester/temperature.rs4
3 files changed, 24 insertions, 17 deletions
diff --git a/src/app/data_harvester/disks.rs b/src/app/data_harvester/disks.rs
index 2d606c14..294288a0 100644
--- a/src/app/data_harvester/disks.rs
+++ b/src/app/data_harvester/disks.rs
@@ -1,6 +1,3 @@
-#[cfg(not(any(target_arch = "aarch64", target_arch = "arm")))]
-use futures::stream::StreamExt;
-
#[derive(Debug, Clone, Default)]
pub struct DiskHarvest {
pub name: String,
@@ -67,10 +64,14 @@ pub async fn get_io_usage(
return Ok(None);
}
+ use futures::StreamExt;
+
let mut io_hash: std::collections::HashMap<String, Option<IOData>> =
std::collections::HashMap::new();
if get_physical {
- let mut physical_counter_stream = heim::disk::io_counters_physical();
+ let physical_counter_stream = heim::disk::io_counters_physical().await?;
+ futures::pin_mut!(physical_counter_stream);
+
while let Some(io) = physical_counter_stream.next().await {
if let Ok(io) = io {
let mount_point = io.device_name().to_str().unwrap_or("Name Unavailable");
@@ -84,7 +85,9 @@ pub async fn get_io_usage(
}
}
} else {
- let mut counter_stream = heim::disk::io_counters();
+ let counter_stream = heim::disk::io_counters().await?;
+ futures::pin_mut!(counter_stream);
+
while let Some(io) = counter_stream.next().await {
if let Ok(io) = io {
let mount_point = io.device_name().to_str().unwrap_or("Name Unavailable");
@@ -110,8 +113,11 @@ pub async fn get_disk_usage(
return Ok(None);
}
+ use futures::StreamExt;
+
let mut vec_disks: Vec<DiskHarvest> = Vec::new();
- let mut partitions_stream = heim::disk::partitions_physical();
+ let partitions_stream = heim::disk::partitions_physical().await?;
+ futures::pin_mut!(partitions_stream);
while let Some(part) = partitions_stream.next().await {
if let Ok(part) = part {
diff --git a/src/app/data_harvester/network.rs b/src/app/data_harvester/network.rs
index 9836cfb0..37c8b46c 100644
--- a/src/app/data_harvester/network.rs
+++ b/src/app/data_harvester/network.rs
@@ -19,11 +19,11 @@ impl NetworkHarvest {
pub async fn get_network_data(
sys: &sysinfo::System, prev_net_access_time: Instant, prev_net_rx: &mut u64,
prev_net_tx: &mut u64, curr_time: Instant, actually_get: bool,
-) -> Option<NetworkHarvest> {
+) -> crate::utils::error::Result<Option<NetworkHarvest>> {
use sysinfo::{NetworkExt, SystemExt};
if !actually_get {
- return None;
+ return Ok(None);
}
let mut total_rx: u64 = 0;
@@ -48,26 +48,27 @@ pub async fn get_network_data(
*prev_net_rx = total_rx;
*prev_net_tx = total_tx;
- Some(NetworkHarvest {
+ Ok(Some(NetworkHarvest {
rx,
tx,
total_rx,
total_tx,
- })
+ }))
}
#[cfg(not(any(target_os = "windows", target_arch = "aarch64", target_arch = "arm")))]
pub async fn get_network_data(
prev_net_access_time: Instant, prev_net_rx: &mut u64, prev_net_tx: &mut u64,
curr_time: Instant, actually_get: bool,
-) -> Option<NetworkHarvest> {
+) -> crate::utils::error::Result<Option<NetworkHarvest>> {
use futures::StreamExt;
if !actually_get {
- return None;
+ return Ok(None);
}
- let mut io_data = heim::net::io_counters();
+ let io_data = heim::net::io_counters().await?;
+ futures::pin_mut!(io_data);
let mut total_rx: u64 = 0;
let mut total_tx: u64 = 0;
@@ -91,10 +92,10 @@ pub async fn get_network_data(
*prev_net_rx = total_rx;
*prev_net_tx = total_tx;
- Some(NetworkHarvest {
+ Ok(Some(NetworkHarvest {
rx,
tx,
total_rx,
total_tx,
- })
+ }))
}
diff --git a/src/app/data_harvester/temperature.rs b/src/app/data_harvester/temperature.rs
index c3925ceb..470b1dbb 100644
--- a/src/app/data_harvester/temperature.rs
+++ b/src/app/data_harvester/temperature.rs
@@ -64,6 +64,7 @@ pub async fn get_temperature_data(
temp_type: &TemperatureType, actually_get: bool,
) -> crate::utils::error::Result<Option<Vec<TempHarvest>>> {
use futures::StreamExt;
+ use heim::units::thermodynamic_temperature;
if !actually_get {
return Ok(None);
@@ -71,8 +72,7 @@ pub async fn get_temperature_data(
let mut temperature_vec: Vec<TempHarvest> = Vec::new();
- use heim::units::thermodynamic_temperature;
- let mut sensor_data = heim::sensors::temperatures();
+ let mut sensor_data = heim::sensors::temperatures().boxed_local();
while let Some(sensor) = sensor_data.next().await {
if let Ok(sensor) = sensor {
temperature_vec.push(TempHarvest {