aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorTomasz Kramkowski <tomasz@kramkow.ski>2025-06-27 17:39:42 +0100
committerTomasz Kramkowski <tomasz@kramkow.ski>2025-06-27 17:39:42 +0100
commit1fde6642082ece4b6c64e29f2983e0f988ce2b59 (patch)
treeb7c9aefce7f298f152434b29608122cb4d073864 /src/main.rs
parent4504ed4b3cec20503a45d4cf9b2dfd1691b27e59 (diff)
downloadmqttr-1fde6642082ece4b6c64e29f2983e0f988ce2b59.tar.gz
mqttr-1fde6642082ece4b6c64e29f2983e0f988ce2b59.tar.xz
mqttr-1fde6642082ece4b6c64e29f2983e0f988ce2b59.zip
Reduce nesting depth
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/main.rs b/src/main.rs
index 266e915..bc9a7b5 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -79,17 +79,18 @@ async fn main() -> anyhow::Result<()> {
match notification? {
Incoming(Packet::Publish(p)) => {
for (topic, programs) in conf.routes.iter() {
- if topic_match(&topic, &p.topic) {
- for program in programs {
- // TODO: Switch to moro_local to avoid this ewwyness
- let program = program.clone();
- let p = p.clone();
- tokio::spawn(async move {
- if let Err(e) = run(&program, &p).await {
- eprintln!("error: Failed to run {program:?}: {e:?}");
- }
- });
- }
+ if !topic_match(&topic, &p.topic) {
+ continue;
+ }
+ for program in programs {
+ // TODO: Switch to moro_local to avoid this ewwyness
+ let program = program.clone();
+ let p = p.clone();
+ tokio::spawn(async move {
+ if let Err(e) = run(&program, &p).await {
+ eprintln!("error: Failed to run {program:?}: {e:?}");
+ }
+ });
}
}
}