Repository: quartiq/minimq
Pull request #166 (2025-01-05 11:48:20)

feat: update embedded-nal to 0.9


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ea4e94a..10f89ca 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,8 @@ 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.
+  MSRV becomes 1.77.0.
 
 # [0.9.0] - 2024-04-29
 
diff --git a/Cargo.toml b/Cargo.toml
index cea4c67..5611105 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"
@@ -23,7 +24,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 = []
@@ -34,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"
diff --git a/src/broker.rs b/src/broker.rs
index 95eef32..0a43255 100644
--- a/src/broker.rs
+++ b/src/broker.rs
@@ -1,6 +1,9 @@
 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/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<IpBroker> = 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<IpBroker> = 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<IpBroker> = 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<IpBroker> = 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<IpBroker> = ConfigBuilder::new(localhost.into(), &mut buffer)
             .session_state(BufferConfig::Minimum(20));
 
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(),
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};


Test patch:
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