aboutsummaryrefslogtreecommitdiff
path: root/src/run.rs
diff options
context:
space:
mode:
authorMustafa Salih <37256744+MustafaSalih1993@users.noreply.github.com>2021-06-04 22:14:02 +0300
committerGitHub <noreply@github.com>2021-06-04 22:14:02 +0300
commita66c94a1f836b56897a3b5151f93aaa327efc6bd (patch)
tree2aba52ed10c1288f6d837c18a2e3d58101a912f6 /src/run.rs
parentedea2fcb3db9243c6dedead90cd9dfd715c89a90 (diff)
Added local ip (#61)
* added new block/local ip * added local ip block * added localip in config file * edited localip default to false
Diffstat (limited to 'src/run.rs')
-rw-r--r--src/run.rs22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/run.rs b/src/run.rs
index 3a5186b..2ec6889 100644
--- a/src/run.rs
+++ b/src/run.rs
@@ -7,15 +7,13 @@ use async_std::task;
use async_std::task::sleep;
use futures::future;
use futures::stream::StreamExt;
-use std::time::Duration;
use std::future::Future;
-
-
+use std::time::Duration;
async fn init_block<F, Fut>(tx: Sender<ThreadsData>, block: F, delay: f64)
where
F: Fn() -> Fut,
- Fut: Future<Output=ThreadsData>
+ Fut: Future<Output = ThreadsData>,
{
loop {
let _ = tx.send(block().await).await;
@@ -37,6 +35,12 @@ pub async fn run(mut blocks: BlockManager) {
task::spawn(b);
}
+ // local ip task
+ if CONFIG.local_ip.enabled {
+ let b = init_block(tx.clone(), local_ip::get_local_ip, CONFIG.local_ip.delay);
+ task::spawn(b);
+ }
+
// spotify task
if CONFIG.spotify.enabled {
let b = init_block(tx.clone(), spotify::get_spotify, CONFIG.spotify.delay);
@@ -56,17 +60,13 @@ pub async fn run(mut blocks: BlockManager) {
}
// Disk task
- if
- /*CONFIG.disk.enabled*/
- false {
+ if CONFIG.disk.enabled {
let b = init_block(tx.clone(), disk::get_disk, CONFIG.disk.delay);
task::spawn(b);
}
// Memory task
- if
- /*CONFIG.memory.enabled*/
- false {
+ if CONFIG.memory.enabled {
let b = init_block(tx.clone(), memory::get_memory, CONFIG.memory.delay);
task::spawn(b);
}
@@ -111,8 +111,6 @@ pub async fn run(mut blocks: BlockManager) {
let b = init_block(tx, time::get_time, CONFIG.time.delay);
task::spawn(b);
- // NOTE: order matters to the final format
-
rx.for_each(|data| {
blocks.update(data);
future::ready(())