From d9e95ec9a37a27ebaa54c2dc658bf032ea2fe40a Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 9 Sep 2024 09:39:38 +0200 Subject: [PATCH 1/8] Fix clippy: Use type alias for complex type Signed-off-by: Matthias Beyer --- src/client/send.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/client/send.rs b/src/client/send.rs index 204b77ee..cc281209 100644 --- a/src/client/send.rs +++ b/src/client/send.rs @@ -221,6 +221,7 @@ pub(crate) struct ClientHandlers { } pub type OnPacketRecvFn = Box; +pub type OnPacketRefRecvFn = Box; pub type OnQos1AcknowledgeFn = Box; impl Default for ClientHandlers { @@ -313,7 +314,7 @@ pub struct Publish { pub qos: QualityOfService, pub retain: bool, pub payload: MqttPayload, - pub on_packet_recv: Option>, + pub on_packet_recv: Option, } pub struct Published { @@ -379,14 +380,11 @@ pub struct PublishQos1 { pub topic: crate::topic::MqttTopic, pub retain: bool, pub payload: MqttPayload, - on_packet_recv: Option>, + on_packet_recv: Option, } impl PublishQos1 { - pub fn with_on_packet_recv( - mut self, - on_packet_recv: Box, - ) -> Self { + pub fn with_on_packet_recv(mut self, on_packet_recv: OnPacketRefRecvFn) -> Self { self.on_packet_recv = Some(on_packet_recv); self } @@ -396,14 +394,11 @@ pub struct PublishQos2 { pub topic: crate::topic::MqttTopic, pub retain: bool, pub payload: MqttPayload, - on_packet_recv: Option>, + on_packet_recv: Option, } impl PublishQos2 { - pub fn with_on_packet_recv( - mut self, - on_packet_recv: Box, - ) -> Self { + pub fn with_on_packet_recv(mut self, on_packet_recv: OnPacketRefRecvFn) -> Self { self.on_packet_recv = Some(on_packet_recv); self } From 23e0b488068cf7d67171f6ace68223c5df6efe0c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 9 Sep 2024 09:40:08 +0200 Subject: [PATCH 2/8] Fix clippy: Use is_err() instead of match Signed-off-by: Matthias Beyer --- src/client/receive.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/receive.rs b/src/client/receive.rs index e08a3e9d..26f50b97 100644 --- a/src/client/receive.rs +++ b/src/client/receive.rs @@ -146,7 +146,7 @@ async fn handle_pubcomp( tracing::trace!("Removed packet id from outstanding packets"); if let Some(callback) = inner.outstanding_callbacks.take_qos2_complete(pident) { - if let Err(_) = callback.on_complete.send(packet.clone()) { + if callback.on_complete.send(packet.clone()).is_err() { tracing::trace!("Could not send ack, receiver was dropped.") } } else { @@ -190,7 +190,7 @@ async fn handle_puback( tracing::trace!("Removed packet id from outstanding packets"); if let Some(callback) = inner.outstanding_callbacks.take_qos1(pident) { - if let Err(_) = callback.on_acknowledge.send(puback.clone()) { + if callback.on_acknowledge.send(puback.clone()).is_err() { tracing::trace!("Could not send ack, receiver was dropped.") } } @@ -257,7 +257,7 @@ async fn handle_pubrec( conn_state.conn_write.send(pubrel).await.map_err(drop)?; if let Some(callback) = inner.outstanding_callbacks.take_qos2_receive(pident) { - if let Err(_) = callback.on_receive.send(packet.clone()) { + if callback.on_receive.send(packet.clone()).is_err() { tracing::trace!("Could not send ack, receiver was dropped.") } } else { From 256f8efc9bc188a0541aa04c1e3a372413e49154 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 9 Sep 2024 09:40:59 +0200 Subject: [PATCH 3/8] Fix clippy: Use from() instead of try_from() here Signed-off-by: Matthias Beyer --- src/client/receive.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/client/receive.rs b/src/client/receive.rs index 26f50b97..df99e279 100644 --- a/src/client/receive.rs +++ b/src/client/receive.rs @@ -178,8 +178,7 @@ async fn handle_puback( todo!() }; - let pident = PacketIdentifier::try_from(mpuback.packet_identifier) - .expect("Zero PacketIdentifier not valid here"); + let pident = PacketIdentifier::from(mpuback.packet_identifier); tracing::Span::current().record("packet_identifier", tracing::field::display(pident)); if session_state @@ -225,8 +224,7 @@ async fn handle_pubrec( tracing::error!("No session state found"); todo!() }; - let pident = PacketIdentifier::try_from(pubrec.packet_identifier) - .expect("zero PacketIdentifier not valid here"); + let pident = PacketIdentifier::from(pubrec.packet_identifier); tracing::Span::current().record("packet_identifier", tracing::field::display(pident)); if session_state From f7bce9437dcc9b3b2551367d11c74438ecfb0c30 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 9 Sep 2024 09:41:17 +0200 Subject: [PATCH 4/8] Fix: Remove unused imports Signed-off-by: Matthias Beyer --- src/client/mod.rs | 1 - src/client/send.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/src/client/mod.rs b/src/client/mod.rs index 8ff460f5..ff4ed370 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -14,7 +14,6 @@ use std::sync::Arc; use futures::lock::Mutex; -use self::send::Acknowledge; use self::send::Callbacks; use self::send::ClientHandlers; use self::state::ConnectState; diff --git a/src/client/send.rs b/src/client/send.rs index cc281209..80c2d01d 100644 --- a/src/client/send.rs +++ b/src/client/send.rs @@ -7,7 +7,6 @@ use std::collections::HashMap; use std::collections::VecDeque; -use futures::FutureExt; use mqtt_format::v5::integers::VARIABLE_INTEGER_MAX; use mqtt_format::v5::packets::publish::MPublish; use tracing::Instrument; From caaa877470b13e07afbaecc17724fe731286e960 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 9 Sep 2024 09:42:29 +0200 Subject: [PATCH 5/8] Fix clippy: Allow unused code for now Signed-off-by: Matthias Beyer --- src/client/state.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/client/state.rs b/src/client/state.rs index 0c707d31..4c4b87c4 100644 --- a/src/client/state.rs +++ b/src/client/state.rs @@ -48,6 +48,7 @@ impl TransportWriter { } } +#[allow(unused)] pub(super) struct ConnectState { pub(super) session_present: bool, pub(super) receive_maximum: Option, @@ -66,6 +67,7 @@ pub(super) struct ConnectState { } pub(super) struct SessionState { + #[allow(unused)] pub(super) client_identifier: MqttString, pub(super) outstanding_packets: OutstandingPackets, } @@ -111,6 +113,7 @@ impl OutstandingPackets { self.outstanding_packets.contains_key(&ident) } + #[allow(unused)] pub fn iter_in_send_order( &self, ) -> impl Iterator { From 41ade1d3a2962d055737ca7a9dfc1131d8e06218 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 9 Sep 2024 09:45:45 +0200 Subject: [PATCH 6/8] Fix clippy: Mask unused variable Signed-off-by: Matthias Beyer --- cloudmqtt-bin/src/bin/client.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudmqtt-bin/src/bin/client.rs b/cloudmqtt-bin/src/bin/client.rs index e5f89f24..36f31b95 100644 --- a/cloudmqtt-bin/src/bin/client.rs +++ b/cloudmqtt-bin/src/bin/client.rs @@ -64,7 +64,7 @@ async fn main() { .await .unwrap(); let connected = client.connect(connector).await.unwrap(); - let background = tokio::task::spawn(connected.background_task); + let _background = tokio::task::spawn(connected.background_task); client .publish(Publish { From 381ed0d2b35fda0a0d8b0dc40f9b2503728d8bf7 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 9 Sep 2024 09:46:10 +0200 Subject: [PATCH 7/8] Fix: Remove unused import Signed-off-by: Matthias Beyer --- cloudmqtt-bin/src/bin/client.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/cloudmqtt-bin/src/bin/client.rs b/cloudmqtt-bin/src/bin/client.rs index 36f31b95..51093e55 100644 --- a/cloudmqtt-bin/src/bin/client.rs +++ b/cloudmqtt-bin/src/bin/client.rs @@ -11,7 +11,6 @@ use cloudmqtt::client::connect::MqttClientConnector; use cloudmqtt::client::send::Publish; use cloudmqtt::client::MqttClient; use cloudmqtt::transport::MqttConnectTransport; -use futures::FutureExt; use tokio::net::TcpStream; use tracing_subscriber::layer::SubscriberExt; use tracing_subscriber::util::SubscriberInitExt; From 01c2379ca2056508cd766b58767f92cb757e4ef2 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 9 Sep 2024 09:53:34 +0200 Subject: [PATCH 8/8] Remove winnow debug feature, which makes CI take weeks Signed-off-by: Matthias Beyer --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 02666904..a74fbe04 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,8 +15,8 @@ categories = ["embedded"] [workspace] members = ["cloudmqtt-bin", "mqtt-format"] -[features] -debug = ["winnow/debug"] +#[features] +#debug = ["winnow/debug"] [dependencies] futures = "0.3.30"