Skip to content

Commit

Permalink
chore: fix clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
markhaehnel committed Nov 28, 2023
1 parent 7074229 commit 35aec54
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
12 changes: 5 additions & 7 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ impl Client {
let msg_opt = self.stream.next().await;

if let Some(Some(msg)) = msg_opt {
self.tx.send(parse_message(msg)?)?;
self.tx.send(parse_message(&msg)?)?;
} else {
// A "None" means we were disconnected. Try to reconnect...
self.tx.send(Message::Disconnected)?;

while let Err(_) = self.client.reconnect().await {
while (self.client.reconnect().await).is_err() {
tokio::time::sleep(Duration::from_secs(1)).await;
self.tx.send(Message::Reconnecting)?;
}
Expand Down Expand Up @@ -109,11 +109,9 @@ impl Client {
Ok(())
}

fn subscibe_to_device_report(&mut self) -> Result<()> {
fn subscibe_to_device_report(&mut self) {
self.client
.subscribe(&self.topic_device_report, paho_mqtt::QOS_0);

Ok(())
}

/// Runs the Bambu MQTT client.
Expand All @@ -126,10 +124,10 @@ impl Client {
pub async fn run(&mut self) -> Result<()> {
self.connect().await?;

self.subscibe_to_device_report()?;
self.subscibe_to_device_report();

loop {
Client::poll(self).await?;
Self::poll(self).await?;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::Result;

use crate::message::Message;

pub(crate) fn parse_message(message: paho_mqtt::Message) -> Result<Message> {
pub(crate) fn parse_message(message: &paho_mqtt::Message) -> Result<Message> {
let payload_str = String::from_utf8(message.payload().to_vec())?;
Ok(Message::Info(payload_str))
}
Expand All @@ -19,7 +19,7 @@ mod tests {
paho_mqtt::QOS_2,
);

let result = parse_message(message).unwrap();
let result = parse_message(&message).unwrap();

assert_eq!(result, Message::Info(r#"{ "hello": "world" }"#.into()));
}
Expand Down

0 comments on commit 35aec54

Please sign in to comment.