Skip to content

Commit 80b355c

Browse files
committed
fix(lint): fix cargo clippy warnings
Signed-off-by: Deep Panchal <[email protected]>
1 parent db21891 commit 80b355c

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

src/main.rs

+18-22
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use aws_iot_device_sdk_rust::{
33
};
44
use clap::{Parser, Subcommand};
55
use colored::*;
6-
use env_logger;
76
use log::debug;
87
use regex::Regex;
98
use serde_json::Value;
@@ -172,29 +171,26 @@ async fn main() -> Result<(), Box<dyn Error>> {
172171

173172
let recv_thread = task::spawn(async move {
174173
loop {
175-
match receiver.lock().await.recv().await {
176-
Ok(Packet::Publish(p)) => {
177-
let topic = p.topic;
178-
let payload = match String::from_utf8(p.payload.to_vec()) {
179-
Ok(s) => s,
180-
Err(e) => {
181-
eprintln!("Invalid UTF-8 payload: {}", e);
182-
continue;
183-
}
184-
};
185-
if let Some(ref regex) = include_regex {
186-
if !regex.is_match(&topic) {
187-
continue;
188-
}
174+
if let Ok(Packet::Publish(p)) = receiver.lock().await.recv().await {
175+
let topic = p.topic;
176+
let payload = match String::from_utf8(p.payload.to_vec()) {
177+
Ok(s) => s,
178+
Err(e) => {
179+
eprintln!("Invalid UTF-8 payload: {}", e);
180+
continue;
181+
}
182+
};
183+
if let Some(ref regex) = include_regex {
184+
if !regex.is_match(&topic) {
185+
continue;
189186
}
190-
if let Some(ref regex) = exclude_regex {
191-
if regex.is_match(&topic) {
192-
continue;
193-
}
187+
}
188+
if let Some(ref regex) = exclude_regex {
189+
if regex.is_match(&topic) {
190+
continue;
194191
}
195-
format_mqtt_log_entry(&topic, &payload);
196192
}
197-
_ => (),
193+
format_mqtt_log_entry(&topic, &payload);
198194
}
199195
}
200196
});
@@ -217,7 +213,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
217213
let receiver = iot_core_client.lock().await.get_receiver().await;
218214
let receiver = Arc::new(Mutex::new(receiver));
219215
let drain_task = task::spawn(async move {
220-
loop {
216+
while (receiver.lock().await.recv().await).is_ok() {
221217
match receiver.lock().await.recv().await {
222218
Ok(_) => {} // Ignore incoming events
223219
Err(_) => break, // Exit if the channel is closed

0 commit comments

Comments
 (0)