From 4cee3edc417010d3d23ba6098d3209c5fcd1109e Mon Sep 17 00:00:00 2001 From: Kshitij Sharma Date: Fri, 6 Sep 2024 09:19:25 +0100 Subject: [PATCH] Fix all errors from old code --- config/src/lib.rs | 8 ++++---- lib/core/src/mqtt.rs | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/config/src/lib.rs b/config/src/lib.rs index 527068f..c699a3c 100644 --- a/config/src/lib.rs +++ b/config/src/lib.rs @@ -1,5 +1,4 @@ use serde::{Deserialize, Serialize}; -use serde_yml; use std::collections::HashMap; #[derive(Debug, Serialize, Deserialize, PartialEq)] @@ -47,7 +46,7 @@ pub struct PodConfig { impl PodConfig { fn new(raw_config: &str) -> Result { - let config = match serde_yml::from_str::(&raw_config) { + let config = match serde_yml::from_str::(raw_config) { Ok(mut config) => { config.pod_ids = config.pods.keys().cloned().collect(); Ok(config) @@ -142,9 +141,10 @@ mod tests { min: -150 max: 150 "#; - let mut config = PodConfig::new(raw_config).unwrap(); + let config = PodConfig::new(raw_config).unwrap(); assert!(config.pod_ids.len() == 2); - assert!(config.pod_ids.sort() == vec!["pod_1", "pod_2"].sort()); + assert!(config.pod_ids[0] == "pod_1" || config.pod_ids[1] == "pod_1"); + assert!(config.pod_ids[0] == "pod_2" || config.pod_ids[1] == "pod_2"); let pod1 = config.pods.get("pod_1").unwrap(); let pod2 = config.pods.get("pod_2").unwrap(); assert_eq!(pod1.name, "Pod 1"); diff --git a/lib/core/src/mqtt.rs b/lib/core/src/mqtt.rs index 385bbd8..3a2523a 100644 --- a/lib/core/src/mqtt.rs +++ b/lib/core/src/mqtt.rs @@ -45,7 +45,7 @@ impl<'a> HypedMqttClient<'a, TcpSocket<'a>, CountingRng> { } /// Initialise the MQTT client configuration with the given client ID -pub fn initialise_mqtt_config<'a>(client_id: &'a str) -> ClientConfig<'a, 5, CountingRng> { +pub fn initialise_mqtt_config(client_id: &str) -> ClientConfig<'_, 5, CountingRng> { let mut config = ClientConfig::new( rust_mqtt::client::client_config::MqttVersion::MQTTv5, CountingRng(20000), @@ -119,11 +119,11 @@ impl<'a, T: embedded_io_async::Read + embedded_io_async::Write, R: rand_core::Rn Err(mqtt_error) => match mqtt_error { ReasonCode::NetworkError => { info!("MQTT Network Error"); - return Err(ReasonCode::NetworkError); + Err(ReasonCode::NetworkError) } _ => { warn!("Other MQTT Error: {:?}", mqtt_error); - return Err(mqtt_error); + Err(mqtt_error) } }, }