From 8d2d2db096f7477bb7cb90615048f07a1bc6e52b Mon Sep 17 00:00:00 2001 From: Oleksandr Babak Date: Sun, 5 Jan 2025 12:47:57 +0100 Subject: [PATCH 1/7] feat: update embedded-nal to 0.9 --- Cargo.toml | 2 +- src/broker.rs | 4 ++-- src/network_manager.rs | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cea4c67..a611b8d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ embedded-time = "0.12" varint-rs = {version = "2.2", default-features = false } serde = { version = "1", features = ["derive"], default-features = false } smlang = "0.6.0" -embedded-nal = "0.8" +embedded-nal = "0.9" [features] default = [] diff --git a/src/broker.rs b/src/broker.rs index 95eef32..513409b 100644 --- a/src/broker.rs +++ b/src/broker.rs @@ -1,6 +1,6 @@ use crate::{warn, MQTT_INSECURE_DEFAULT_PORT}; -use core::convert::TryFrom; -use embedded_nal::{nb, AddrType, Dns, IpAddr, Ipv4Addr, SocketAddr}; +use core::{convert::TryFrom, net::{IpAddr, Ipv4Addr, SocketAddr}}; +use embedded_nal::{nb, AddrType, Dns}; /// A type that allows us to (eventually) determine the broker address. pub trait Broker { diff --git a/src/network_manager.rs b/src/network_manager.rs index 0af0c89..7e7afd0 100644 --- a/src/network_manager.rs +++ b/src/network_manager.rs @@ -6,7 +6,8 @@ //! stack to be used to transmit buffers that may be stored internally in other structs without //! violating Rust's borrow rules. use crate::{message_types::ControlPacket, packets::Pub}; -use embedded_nal::{nb, SocketAddr, TcpClientStack, TcpError}; +use core::net::SocketAddr; +use embedded_nal::{nb, TcpClientStack, TcpError}; use serde::Serialize; use crate::{Error, ProtocolError}; From e23e51bae4a8522a1be83389d349a3cf809451cb Mon Sep 17 00:00:00 2001 From: Oleksandr Babak Date: Mon, 6 Jan 2025 18:01:27 +0100 Subject: [PATCH 2/7] chore: changelog bumb about `embedded-nal` --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea4e94a..154944c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This document describes the changes to Minimq between releases. ## Changed * The `Publication::finish()` API was removed in favor of a new `Publication::respond()` API for constructing replies to previously received messages. +* [breaking] `embedded-nal` bumped. Now `core::net::SocketAddr` and related ip types are used. # [0.9.0] - 2024-04-29 From dd831f28a81b7dade4af2db29dc82fb99045c947 Mon Sep 17 00:00:00 2001 From: Oleksandr Babak Date: Sun, 12 Jan 2025 14:09:55 +0100 Subject: [PATCH 3/7] feat: add msrv to CHANGELOG.md and manifest --- CHANGELOG.md | 1 + Cargo.toml | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 154944c..10f89ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ This document describes the changes to Minimq between releases. * The `Publication::finish()` API was removed in favor of a new `Publication::respond()` API for constructing replies to previously received messages. * [breaking] `embedded-nal` bumped. Now `core::net::SocketAddr` and related ip types are used. + MSRV becomes 1.77.0. # [0.9.0] - 2024-04-29 diff --git a/Cargo.toml b/Cargo.toml index a611b8d..a5a5231 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,7 @@ readme = "README.md" categories = ["embedded", "no-std", "database", "encoding"] keywords = ["mqtt", "embedded", "client"] license = "MIT" +rust-version = "1.77.0" [dependencies] bit_field = "0.10.0" From 52573802d59eb4ee12b9640c62c91678cf7deab9 Mon Sep 17 00:00:00 2001 From: Oleksandr Babak Date: Mon, 13 Jan 2025 21:31:20 +0100 Subject: [PATCH 4/7] chore: cargo fmt --- src/broker.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/broker.rs b/src/broker.rs index 513409b..0a43255 100644 --- a/src/broker.rs +++ b/src/broker.rs @@ -1,5 +1,8 @@ use crate::{warn, MQTT_INSECURE_DEFAULT_PORT}; -use core::{convert::TryFrom, net::{IpAddr, Ipv4Addr, SocketAddr}}; +use core::{ + convert::TryFrom, + net::{IpAddr, Ipv4Addr, SocketAddr}, +}; use embedded_nal::{nb, AddrType, Dns}; /// A type that allows us to (eventually) determine the broker address. From 776119bffd36dd10ef4f3f95026eb702f1c975dc Mon Sep 17 00:00:00 2001 From: Oleksandr Babak Date: Tue, 14 Jan 2025 08:40:05 +0100 Subject: [PATCH 5/7] chore: fix tests after embedded-nal bump --- src/config.rs | 11 ++++++----- tests/at_least_once_subscription.rs | 2 +- tests/deferred_payload.rs | 2 +- tests/exactly_once_subscription.rs | 2 +- tests/exactly_once_transmission.rs | 2 +- tests/integration_test.rs | 2 +- tests/poll_result.rs | 2 +- tests/reconnection.rs | 2 +- tests/stack/mod.rs | 8 ++++---- 9 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/config.rs b/src/config.rs index 4549549..bcb6691 100644 --- a/src/config.rs +++ b/src/config.rs @@ -253,11 +253,12 @@ impl<'a, Broker: crate::Broker> ConfigBuilder<'a, Broker> { mod tests { use super::*; use crate::broker::IpBroker; + use core::net::IpAddr; #[test] pub fn basic_config() { let mut buffer = [0; 30]; - let localhost: embedded_nal::IpAddr = "127.0.0.1".parse().unwrap(); + let localhost: IpAddr = "127.0.0.1".parse().unwrap(); let builder: ConfigBuilder = ConfigBuilder::new(localhost.into(), &mut buffer); let config = builder.build(); @@ -269,7 +270,7 @@ mod tests { #[test] pub fn without_session_state() { let mut buffer = [0; 30]; - let localhost: embedded_nal::IpAddr = "127.0.0.1".parse().unwrap(); + let localhost: IpAddr = "127.0.0.1".parse().unwrap(); let builder: ConfigBuilder = ConfigBuilder::new(localhost.into(), &mut buffer) .session_state(BufferConfig::Exactly(0)); @@ -282,7 +283,7 @@ mod tests { #[test] pub fn with_exact_sizes() { let mut buffer = [0; 30]; - let localhost: embedded_nal::IpAddr = "127.0.0.1".parse().unwrap(); + let localhost: IpAddr = "127.0.0.1".parse().unwrap(); let builder: ConfigBuilder = ConfigBuilder::new(localhost.into(), &mut buffer) .session_state(BufferConfig::Exactly(8)) .rx_buffer(BufferConfig::Exactly(4)) @@ -297,7 +298,7 @@ mod tests { #[test] pub fn with_max() { let mut buffer = [0; 30]; - let localhost: embedded_nal::IpAddr = "127.0.0.1".parse().unwrap(); + let localhost: IpAddr = "127.0.0.1".parse().unwrap(); let builder: ConfigBuilder = ConfigBuilder::new(localhost.into(), &mut buffer) .session_state(BufferConfig::Maximum(8)); @@ -310,7 +311,7 @@ mod tests { #[test] pub fn with_min() { let mut buffer = [0; 30]; - let localhost: embedded_nal::IpAddr = "127.0.0.1".parse().unwrap(); + let localhost: IpAddr = "127.0.0.1".parse().unwrap(); let builder: ConfigBuilder = ConfigBuilder::new(localhost.into(), &mut buffer) .session_state(BufferConfig::Minimum(20)); diff --git a/tests/at_least_once_subscription.rs b/tests/at_least_once_subscription.rs index dbbba2b..d904cef 100644 --- a/tests/at_least_once_subscription.rs +++ b/tests/at_least_once_subscription.rs @@ -3,7 +3,7 @@ use minimq::{ Minimq, Publication, QoS, }; -use embedded_nal::{self, IpAddr, Ipv4Addr}; +use core::net::{IpAddr, Ipv4Addr}; use std_embedded_time::StandardClock; #[test] diff --git a/tests/deferred_payload.rs b/tests/deferred_payload.rs index fd4e90d..b568fff 100644 --- a/tests/deferred_payload.rs +++ b/tests/deferred_payload.rs @@ -1,6 +1,6 @@ use minimq::{DeferredPublication, Minimq, QoS}; -use embedded_nal::{self, IpAddr, Ipv4Addr}; +use core::net::{IpAddr, Ipv4Addr}; use std_embedded_time::StandardClock; #[test] diff --git a/tests/exactly_once_subscription.rs b/tests/exactly_once_subscription.rs index fbd7c98..c963326 100644 --- a/tests/exactly_once_subscription.rs +++ b/tests/exactly_once_subscription.rs @@ -3,7 +3,7 @@ use minimq::{ Minimq, Publication, QoS, }; -use embedded_nal::{self, IpAddr, Ipv4Addr}; +use core::net::{IpAddr, Ipv4Addr}; use std_embedded_time::StandardClock; #[test] diff --git a/tests/exactly_once_transmission.rs b/tests/exactly_once_transmission.rs index bf10f09..b5b82f1 100644 --- a/tests/exactly_once_transmission.rs +++ b/tests/exactly_once_transmission.rs @@ -1,6 +1,6 @@ use minimq::{Minimq, Publication, QoS}; -use embedded_nal::{self, IpAddr, Ipv4Addr}; +use core::net::{IpAddr, Ipv4Addr}; use std_embedded_time::StandardClock; #[test] diff --git a/tests/integration_test.rs b/tests/integration_test.rs index 98a6c1f..f2b1f2a 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -1,6 +1,6 @@ use minimq::{types::Utf8String, Minimq, Property, Publication, QoS, Will}; -use embedded_nal::{self, IpAddr, Ipv4Addr}; +use core::net::{IpAddr, Ipv4Addr}; use std_embedded_time::StandardClock; #[test] diff --git a/tests/poll_result.rs b/tests/poll_result.rs index c90f00a..07c0fc4 100644 --- a/tests/poll_result.rs +++ b/tests/poll_result.rs @@ -1,6 +1,6 @@ use minimq::{Minimq, Publication, QoS}; -use embedded_nal::{self, IpAddr, Ipv4Addr}; +use core::net::{IpAddr, Ipv4Addr}; use std_embedded_time::StandardClock; #[test] diff --git a/tests/reconnection.rs b/tests/reconnection.rs index 844338a..acb2ac9 100644 --- a/tests/reconnection.rs +++ b/tests/reconnection.rs @@ -3,7 +3,7 @@ use minimq::{ Minimq, Publication, QoS, }; -use embedded_nal::{self, IpAddr, Ipv4Addr}; +use core::net::{IpAddr, Ipv4Addr}; use std_embedded_time::StandardClock; mod stack; diff --git a/tests/stack/mod.rs b/tests/stack/mod.rs index 645ee01..430759d 100644 --- a/tests/stack/mod.rs +++ b/tests/stack/mod.rs @@ -1,7 +1,7 @@ use embedded_nal::{nb, TcpClientStack}; use std::cell::RefCell; use std::io::{Error, ErrorKind, Read, Write}; -use std::net::{SocketAddr, TcpStream}; +use std::net::{IpAddr, SocketAddr, TcpStream}; #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct TcpHandle { @@ -76,8 +76,8 @@ impl TcpSocket { Self { stream: None } } - fn connect(&mut self, remote: embedded_nal::SocketAddr) -> Result<(), Error> { - let embedded_nal::IpAddr::V4(addr) = remote.ip() else { + fn connect(&mut self, remote: SocketAddr) -> Result<(), Error> { + let IpAddr::V4(addr) = remote.ip() else { return Err(Error::new(ErrorKind::Other, "Only IPv4 supported")); }; let remote = SocketAddr::new(addr.octets().into(), remote.port()); @@ -109,7 +109,7 @@ impl<'a> TcpClientStack for MitmStack<'a> { fn connect( &mut self, socket: &mut Self::TcpSocket, - remote: embedded_nal::SocketAddr, + remote: SocketAddr, ) -> nb::Result<(), Self::Error> { let index = self .sockets From 0e3eda2e1717dcdab7c263acd06e61c67e8c331c Mon Sep 17 00:00:00 2001 From: Oleksandr Babak Date: Thu, 16 Jan 2025 13:37:45 +0100 Subject: [PATCH 6/7] fix: use updstream `std-embedded-nal` --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index a5a5231..5611105 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,4 +35,4 @@ unsecure = [] log = "0.4" env_logger = "0.10" std-embedded-time = "0.1" -std-embedded-nal = { git = "https://gitlab.com/ryan-summers/std-embedded-nal", branch = "feature/0.8" } +std-embedded-nal = "0.4.0" From 655c9d2bc46b4875d7aa91be0dc782de5c33d59b Mon Sep 17 00:00:00 2001 From: Oleksandr Babak Date: Thu, 16 Jan 2025 14:04:00 +0100 Subject: [PATCH 7/7] fix(test): doc test had old ip --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index f3daa8f..2c8a5b2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -31,7 +31,7 @@ //! // or QoS::ExactlyOnce has not been completed (PUBCOMP). //! // Connect to a broker at localhost - Use a client ID of "test". //! let mut buffer = [0; 256]; -//! let localhost: embedded_nal::IpAddr = "127.0.0.1".parse().unwrap(); +//! let localhost: std::net::IpAddr = "127.0.0.1".parse().unwrap(); //! let mut mqtt: Minimq<'_, _, _, minimq::broker::IpBroker> = Minimq::new( //! std_embedded_nal::Stack::default(), //! std_embedded_time::StandardClock::default(),