diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fac5de4..09f0845 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,11 +35,11 @@ jobs: - name: Build | Fmt Check run: cargo fmt -- --check - name: Build | Clippy - run: cargo clippy --features std,embedded-svc,edge-nal-embassy --examples --no-deps -- -Dwarnings + run: cargo clippy --features std,embedded-svc,edge-nal-embassy/all --examples --no-deps -- -Dwarnings - name: Build | Clippy - defmt - run: cargo clippy --features std,embedded-svc,edge-nal-embassy,defmt --no-deps -- -Dwarnings + run: cargo clippy --features std,embedded-svc,edge-nal-embassy/all,defmt --no-deps -- -Dwarnings - name: Build | Clippy - log - run: cargo clippy --features std,embedded-svc,edge-nal-embassy,log --examples --no-deps -- -Dwarnings + run: cargo clippy --features std,embedded-svc,edge-nal-embassy/all,log --examples --no-deps -- -Dwarnings - name: Build | Default run: cargo build --features log - name: Build | Non-default diff --git a/Cargo.toml b/Cargo.toml index 7d6796b..0606a4f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "edge-net" -version = "0.10.1" +version = "0.11.0" authors = ["Ivan Markov "] edition = "2021" categories = ["embedded", "hardware-support", "network-programming", "asynchronous"] @@ -15,7 +15,7 @@ rust-version = "1.83" default = ["io"] async-io-mini = ["std", "edge-nal-std/async-io-mini"] std = ["io", "edge-captive/std", "edge-dhcp/std", "edge-http/std", "edge-mdns/std", "edge-raw/std", "edge-mqtt", "edge-ws/std", "edge-nal-std"] -embassy = ["io", "edge-nal-embassy"] +embassy = ["io", "edge-nal-embassy/all"] io = ["edge-captive/io", "edge-dhcp/io", "edge-http/io", "edge-mdns/io", "edge-raw/io", "edge-ws/io", "edge-nal"] log = ["edge-captive/log", "edge-dhcp/log", "edge-http/log", "edge-mdns/log", "edge-raw/log", "edge-ws/log", "edge-nal-embassy?/log"] defmt = ["edge-captive/defmt", "edge-dhcp/defmt", "edge-http/defmt", "edge-mdns/defmt", "edge-raw/defmt", "edge-ws/defmt", "edge-nal-embassy?/defmt"] @@ -40,7 +40,7 @@ anyhow = "1" env_logger = "0.10" embedded-io-async = "0.6" embassy-time = { version = "0.4", features = ["std", "generic-queue-64"] } -embassy-sync = "0.6" +embassy-sync = "0.7" embassy-futures = "0.1" embedded-svc = { version = "0.28", features = ["std"] } futures-lite = "2" @@ -109,20 +109,20 @@ members = [ [workspace.dependencies] embassy-futures = { version = "0.1", default-features = false } -embassy-sync = { version = "0.6", default-features = false } +embassy-sync = { version = "0.7", default-features = false } embassy-time = { version = "0.4", default-features = false } embedded-io-async = { version = "0.6", default-features = false } embedded-svc = { version = "0.28", default-features = false } heapless = { version = "0.8", default-features = false } domain = { version = "0.10", default-features = false, features = ["heapless"] } -edge-captive = { version = "0.5.0", path = "edge-captive", default-features = false } -edge-dhcp = { version = "0.5.0", path = "edge-dhcp", default-features = false } -edge-http = { version = "0.5.1", path = "edge-http", default-features = false } -edge-mdns = { version = "0.5.0", path = "edge-mdns", default-features = false } +edge-captive = { version = "0.6.0", path = "edge-captive", default-features = false } +edge-dhcp = { version = "0.6.0", path = "edge-dhcp", default-features = false } +edge-http = { version = "0.6.0", path = "edge-http", default-features = false } +edge-mdns = { version = "0.6.0", path = "edge-mdns", default-features = false } edge-mqtt = { version = "0.4.0", path = "edge-mqtt", default-features = false } edge-nal = { version = "0.5.0", path = "edge-nal", default-features = false } -edge-raw = { version = "0.5.0", path = "edge-raw", default-features = false } -edge-ws = { version = "0.4.0", path = "edge-ws", default-features = false } +edge-raw = { version = "0.6.0", path = "edge-raw", default-features = false } +edge-ws = { version = "0.5.0", path = "edge-ws", default-features = false } edge-nal-std = { version = "0.5.0", path = "edge-nal-std", default-features = false } -edge-nal-embassy = { version = "0.5.0", path = "edge-nal-embassy", default-features = false } +edge-nal-embassy = { version = "0.6.0", path = "edge-nal-embassy", default-features = false } diff --git a/edge-captive/CHANGELOG.md b/edge-captive/CHANGELOG.md index d727720..f57eccb 100644 --- a/edge-captive/CHANGELOG.md +++ b/edge-captive/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [0.6.0] - 2025-05-29 * Optional `defmt` support via two new features (one has to specify one, or the other, or neither, but not both): * `log` - uses the `log` crate for all logging * `defmt` - uses the `defmt` crate for all logging, and implements `defmt::Format` for all library types that otherwise implement `Debug` and/or `Display` diff --git a/edge-captive/Cargo.toml b/edge-captive/Cargo.toml index 357876f..2b10969 100644 --- a/edge-captive/Cargo.toml +++ b/edge-captive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "edge-captive" -version = "0.5.0" +version = "0.6.0" edition = "2021" rust-version = "1.83" description = "Async + `no_std` + no-alloc implementation of a Captive Portal DNS" diff --git a/edge-captive/src/lib.rs b/edge-captive/src/lib.rs index d8bb48e..3bb59df 100644 --- a/edge-captive/src/lib.rs +++ b/edge-captive/src/lib.rs @@ -1,5 +1,7 @@ #![cfg_attr(not(feature = "std"), no_std)] #![warn(clippy::large_futures)] +#![allow(clippy::uninlined_format_args)] +#![allow(unknown_lints)] use core::fmt::Display; use core::time::Duration; diff --git a/edge-dhcp/CHANGELOG.md b/edge-dhcp/CHANGELOG.md index d09eb9c..76dedd7 100644 --- a/edge-dhcp/CHANGELOG.md +++ b/edge-dhcp/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [0.6.0] - 2025-05-29 * Optional `defmt` support via two new features (one has to specify one, or the other, or neither, but not both): * `log` - uses the `log` crate for all logging * `defmt` - uses the `defmt` crate for all logging, and implements `defmt::Format` for all library types that otherwise implement `Debug` and/or `Display` diff --git a/edge-dhcp/Cargo.toml b/edge-dhcp/Cargo.toml index 052e4bf..8545616 100644 --- a/edge-dhcp/Cargo.toml +++ b/edge-dhcp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "edge-dhcp" -version = "0.5.0" +version = "0.6.0" edition = "2021" rust-version = "1.83" description = "Async + `no_std` + no-alloc implementation of the DHCP protocol" diff --git a/edge-dhcp/src/lib.rs b/edge-dhcp/src/lib.rs index f449c49..92e4baf 100644 --- a/edge-dhcp/src/lib.rs +++ b/edge-dhcp/src/lib.rs @@ -1,5 +1,7 @@ #![cfg_attr(not(feature = "std"), no_std)] #![warn(clippy::large_futures)] +#![allow(clippy::uninlined_format_args)] +#![allow(unknown_lints)] /// This code is a `no_std` and no-alloc modification of https://github.com/krolaw/dhcp4r use core::str::Utf8Error; diff --git a/edge-http/CHANGELOG.md b/edge-http/CHANGELOG.md index 01f79e1..f7771da 100644 --- a/edge-http/CHANGELOG.md +++ b/edge-http/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [0.6.0] - 2025-05-29 * Optional `defmt` support via two new features (one has to specify one, or the other, or neither, but not both): * `log` - uses the `log` crate for all logging * `defmt` - uses the `defmt` crate for all logging, and implements `defmt::Format` for all library types that otherwise implement `Debug` and/or `Display` diff --git a/edge-http/Cargo.toml b/edge-http/Cargo.toml index 51a5ef6..f3bc1c9 100644 --- a/edge-http/Cargo.toml +++ b/edge-http/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "edge-http" -version = "0.5.1" +version = "0.6.0" edition = "2021" rust-version = "1.83" description = "Async + `no_std` + no-alloc implementation of the HTTP protocol" diff --git a/edge-http/src/lib.rs b/edge-http/src/lib.rs index 0083c18..75cddb4 100644 --- a/edge-http/src/lib.rs +++ b/edge-http/src/lib.rs @@ -1,6 +1,8 @@ #![cfg_attr(not(feature = "std"), no_std)] #![allow(async_fn_in_trait)] #![warn(clippy::large_futures)] +#![allow(clippy::uninlined_format_args)] +#![allow(unknown_lints)] use core::fmt::Display; use core::str; diff --git a/edge-mdns/CHANGELOG.md b/edge-mdns/CHANGELOG.md index 94186ab..d5a238d 100644 --- a/edge-mdns/CHANGELOG.md +++ b/edge-mdns/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [0.6.0] - 2025-05-29 * Optional `defmt` support via two new features (one has to specify one, or the other, or neither, but not both): * `log` - uses the `log` crate for all logging * `defmt` - uses the `defmt` crate for all logging, and implements `defmt::Format` for all library types that otherwise implement `Debug` and/or `Display` diff --git a/edge-mdns/Cargo.toml b/edge-mdns/Cargo.toml index 2ab63dc..cf87a19 100644 --- a/edge-mdns/Cargo.toml +++ b/edge-mdns/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "edge-mdns" -version = "0.5.0" +version = "0.6.0" edition = "2021" description = "Async + `no_std` + no-alloc implementation of an mDNS responder" repository = "https://github.com/ivmarkov/edge-net" diff --git a/edge-mdns/src/lib.rs b/edge-mdns/src/lib.rs index fa13cd5..1f75a29 100644 --- a/edge-mdns/src/lib.rs +++ b/edge-mdns/src/lib.rs @@ -1,6 +1,8 @@ #![cfg_attr(not(feature = "std"), no_std)] #![warn(clippy::large_futures)] #![allow(async_fn_in_trait)] +#![allow(clippy::uninlined_format_args)] +#![allow(unknown_lints)] use core::cmp::Ordering; use core::fmt::Display; diff --git a/edge-mqtt/src/lib.rs b/edge-mqtt/src/lib.rs index eb6e09d..cd226e1 100644 --- a/edge-mqtt/src/lib.rs +++ b/edge-mqtt/src/lib.rs @@ -1,3 +1,5 @@ #![warn(clippy::large_futures)] +#![allow(clippy::uninlined_format_args)] +#![allow(unknown_lints)] pub mod io; diff --git a/edge-nal-embassy/CHANGELOG.md b/edge-nal-embassy/CHANGELOG.md index 8dc0254..4e891a7 100644 --- a/edge-nal-embassy/CHANGELOG.md +++ b/edge-nal-embassy/CHANGELOG.md @@ -5,10 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [0.6.0] - 2025-05-29 * Optional `defmt` support via two new features (one has to specify one, or the other, or neither, but not both): * `log` - uses the `log` crate for all logging * `defmt` - uses the `defmt` crate for all logging, and implements `defmt::Format` for all library types that otherwise implement `Debug` and/or `Display` +* Updated to `embassy-net` 0.7 +* Re-export all `embassy-net` features as `edge-nal-embassy` features; `all` feature that enables all features of `embassy-net` ## [0.5.0] - 2025-01-15 * Updated dependencies for compatibility with `embassy-time-driver` v0.2 diff --git a/edge-nal-embassy/Cargo.toml b/edge-nal-embassy/Cargo.toml index 6d403b6..6f76a62 100644 --- a/edge-nal-embassy/Cargo.toml +++ b/edge-nal-embassy/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "edge-nal-embassy" -version = "0.5.0" +version = "0.6.0" edition = "2021" rust-version = "1.83" description = "An implementation of edge-nal based on `embassy-net`" @@ -15,7 +15,20 @@ categories = [ ] [features] +default = ["all"] +all = ["proto-ipv4", "proto-ipv6", "medium-ethernet", "medium-ip", "dns", "udp", "tcp", "multicast", "icmp", "dhcpv4", "dhcpv4-hostname"] defmt = ["dep:defmt", "heapless/defmt-03", "embassy-net/defmt"] +proto-ipv4 = ["embassy-net/proto-ipv4"] +proto-ipv6 = ["embassy-net/proto-ipv6"] +medium-ethernet = ["embassy-net/medium-ethernet"] +medium-ip = ["embassy-net/medium-ip"] +dns = ["embassy-net/dns"] +udp = ["embassy-net/udp"] +tcp = ["embassy-net/tcp"] +icmp = ["embassy-net/icmp"] +multicast = ["embassy-net/multicast"] +dhcpv4 = ["embassy-net/dhcpv4"] +dhcpv4-hostname = ["embassy-net/dhcpv4-hostname"] [dependencies] log = { version = "0.4", default-features = false, optional = true } @@ -23,14 +36,5 @@ defmt = { version = "0.3", optional = true } embedded-io-async = { workspace = true } edge-nal = { workspace = true } heapless = { workspace = true } -# Do not require these features and conditionalize the code instead -embassy-net = { version = "0.6", features = [ - "tcp", - "udp", - "dns", - "proto-ipv6", - "medium-ethernet", - "proto-ipv4", - "multicast", -] } +embassy-net = "0.7" embassy-futures = { workspace = true } diff --git a/edge-nal-embassy/src/lib.rs b/edge-nal-embassy/src/lib.rs index 8f3aced..444aeeb 100644 --- a/edge-nal-embassy/src/lib.rs +++ b/edge-nal-embassy/src/lib.rs @@ -1,23 +1,31 @@ #![no_std] #![allow(async_fn_in_trait)] #![warn(clippy::large_futures)] +#![allow(clippy::uninlined_format_args)] +#![allow(unknown_lints)] use core::cell::{Cell, UnsafeCell}; use core::mem::MaybeUninit; -use core::net::SocketAddr; +use core::net::{IpAddr, SocketAddr}; use core::ptr::NonNull; -use embassy_net::{IpEndpoint, IpListenEndpoint}; +use embassy_net::{IpAddress, IpEndpoint, IpListenEndpoint}; +#[cfg(feature = "dns")] pub use dns::*; +#[cfg(feature = "tcp")] pub use tcp::*; +#[cfg(feature = "udp")] pub use udp::*; // This mod MUST go first, so that the others see its macros. pub(crate) mod fmt; +#[cfg(feature = "dns")] mod dns; +#[cfg(feature = "tcp")] mod tcp; +#[cfg(feature = "udp")] mod udp; pub(crate) struct Pool { @@ -66,26 +74,33 @@ pub(crate) fn to_net_socket(socket: IpEndpoint) -> SocketAddr { SocketAddr::new(socket.addr.into(), socket.port) } -// pub(crate) fn to_net_socket2(socket: IpListenEndpoint) -> SocketAddr { -// SocketAddr::new( -// socket -// .addr -// .map(to_net_addr) -// .unwrap_or(IpAddr::V6(Ipv6Addr::UNSPECIFIED)), -// socket.port, -// ) -// } - -pub(crate) fn to_emb_socket(socket: SocketAddr) -> IpEndpoint { - IpEndpoint { - addr: socket.ip().into(), +pub(crate) fn to_emb_socket(socket: SocketAddr) -> Option { + Some(IpEndpoint { + addr: to_emb_addr(socket.ip())?, port: socket.port(), - } + }) } -pub(crate) fn to_emb_bind_socket(socket: SocketAddr) -> IpListenEndpoint { - IpListenEndpoint { - addr: (!socket.ip().is_unspecified()).then(|| socket.ip().into()), +pub(crate) fn to_emb_bind_socket(socket: SocketAddr) -> Option { + let addr = if socket.ip().is_unspecified() { + None + } else { + Some(to_emb_addr(socket.ip())?) + }; + + Some(IpListenEndpoint { + addr, port: socket.port(), + }) +} + +pub(crate) fn to_emb_addr(addr: IpAddr) -> Option { + match addr { + #[cfg(feature = "proto-ipv4")] + IpAddr::V4(addr) => Some(addr.into()), + #[cfg(feature = "proto-ipv6")] + IpAddr::V6(addr) => Some(addr.into()), + #[allow(unreachable_patterns)] + _ => None, } } diff --git a/edge-nal-embassy/src/tcp.rs b/edge-nal-embassy/src/tcp.rs index d169d64..3c7f359 100644 --- a/edge-nal-embassy/src/tcp.rs +++ b/edge-nal-embassy/src/tcp.rs @@ -44,7 +44,10 @@ impl TcpConnect async fn connect(&self, remote: SocketAddr) -> Result, Self::Error> { let mut socket = TcpSocket::new(self.stack, self.buffers)?; - socket.socket.connect(to_emb_socket(remote)).await?; + socket + .socket + .connect(to_emb_socket(remote).ok_or(TcpError::UnsupportedProto)?) + .await?; Ok(socket) } @@ -82,7 +85,10 @@ impl edge_nal::TcpAccept async fn accept(&self) -> Result<(SocketAddr, Self::Socket<'_>), Self::Error> { let mut socket = TcpSocket::new(self.stack.stack, self.stack.buffers)?; - socket.socket.accept(to_emb_bind_socket(self.local)).await?; + socket + .socket + .accept(to_emb_bind_socket(self.local).ok_or(TcpError::UnsupportedProto)?) + .await?; let local_endpoint = unwrap!(socket.socket.local_endpoint()); @@ -286,6 +292,7 @@ pub enum TcpError { Connect(ConnectError), Accept(AcceptError), NoBuffers, + UnsupportedProto, } impl From for TcpError { @@ -314,6 +321,7 @@ impl embedded_io_async::Error for TcpError { TcpError::Connect(_) => ErrorKind::Other, TcpError::Accept(_) => ErrorKind::Other, TcpError::NoBuffers => ErrorKind::OutOfMemory, + TcpError::UnsupportedProto => ErrorKind::InvalidInput, } } } diff --git a/edge-nal-embassy/src/udp.rs b/edge-nal-embassy/src/udp.rs index a269555..ae36f08 100644 --- a/edge-nal-embassy/src/udp.rs +++ b/edge-nal-embassy/src/udp.rs @@ -1,10 +1,10 @@ -use core::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}; +use core::net::{Ipv4Addr, Ipv6Addr, SocketAddr}; use core::ptr::NonNull; use edge_nal::{MulticastV4, MulticastV6, Readable, UdpBind, UdpReceive, UdpSend, UdpSplit}; use embassy_net::udp::{BindError, PacketMetadata, RecvError, SendError}; -use embassy_net::{MulticastError, Stack}; +use embassy_net::Stack; use embedded_io_async::{ErrorKind, ErrorType}; @@ -49,7 +49,9 @@ impl Udp async fn bind(&self, local: SocketAddr) -> Result, Self::Error> { let mut socket = UdpSocket::new(self.stack, self.buffers)?; - socket.socket.bind(to_emb_bind_socket(local))?; + socket + .socket + .bind(to_emb_bind_socket(local).ok_or(UdpError::UnsupportedProto)?)?; Ok(socket) } @@ -58,6 +60,7 @@ impl Udp /// A UDP socket /// Implements the `UdpReceive` `UdpSend` and `UdpSplit` traits from `edge-nal` pub struct UdpSocket<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> { + #[allow(unused)] stack: embassy_net::Stack<'d>, socket: embassy_net::udp::UdpSocket<'d>, stack_buffers: &'d UdpBuffers, @@ -125,7 +128,12 @@ impl Udp for UdpSocket<'_, N, TX_SZ, RX_SZ, M> { async fn send(&mut self, remote: SocketAddr, data: &[u8]) -> Result<(), Self::Error> { - self.socket.send_to(data, to_emb_socket(remote)).await?; + self.socket + .send_to( + data, + to_emb_socket(remote).ok_or(UdpError::UnsupportedProto)?, + ) + .await?; Ok(()) } @@ -151,7 +159,12 @@ impl Udp for &UdpSocket<'_, N, TX_SZ, RX_SZ, M> { async fn send(&mut self, remote: SocketAddr, data: &[u8]) -> Result<(), Self::Error> { - self.socket.send_to(data, remote).await?; + self.socket + .send_to( + data, + to_emb_socket(remote).ok_or(UdpError::UnsupportedProto)?, + ) + .await?; Ok(()) } @@ -189,22 +202,42 @@ impl Mul { async fn join_v4( &mut self, - multicast_addr: Ipv4Addr, + #[allow(unused)] multicast_addr: Ipv4Addr, _interface: Ipv4Addr, ) -> Result<(), Self::Error> { - self.stack - .join_multicast_group(IpAddr::V4(multicast_addr))?; + #[cfg(feature = "multicast")] + { + self.stack.join_multicast_group( + crate::to_emb_addr(core::net::IpAddr::V4(multicast_addr)) + .ok_or(UdpError::UnsupportedProto)?, + )?; + } + + #[cfg(not(feature = "multicast"))] + { + Err(UdpError::UnsupportedProto)?; + } Ok(()) } async fn leave_v4( &mut self, - multicast_addr: Ipv4Addr, + #[allow(unused)] multicast_addr: Ipv4Addr, _interface: Ipv4Addr, ) -> Result<(), Self::Error> { - self.stack - .leave_multicast_group(IpAddr::V4(multicast_addr))?; + #[cfg(feature = "multicast")] + { + self.stack.leave_multicast_group( + crate::to_emb_addr(core::net::IpAddr::V4(multicast_addr)) + .ok_or(UdpError::UnsupportedProto)?, + )?; + } + + #[cfg(not(feature = "multicast"))] + { + Err(UdpError::UnsupportedProto)?; + } Ok(()) } @@ -215,22 +248,42 @@ impl Mul { async fn join_v6( &mut self, - multicast_addr: Ipv6Addr, + #[allow(unused)] multicast_addr: Ipv6Addr, _interface: u32, ) -> Result<(), Self::Error> { - self.stack - .join_multicast_group(IpAddr::V6(multicast_addr))?; + #[cfg(feature = "multicast")] + { + self.stack.join_multicast_group( + crate::to_emb_addr(core::net::IpAddr::V6(multicast_addr)) + .ok_or(UdpError::UnsupportedProto)?, + )?; + } + + #[cfg(not(feature = "multicast"))] + { + Err(UdpError::UnsupportedProto)?; + } Ok(()) } async fn leave_v6( &mut self, - multicast_addr: Ipv6Addr, + #[allow(unused)] multicast_addr: Ipv6Addr, _interface: u32, ) -> Result<(), Self::Error> { - self.stack - .leave_multicast_group(IpAddr::V6(multicast_addr))?; + #[cfg(feature = "multicast")] + { + self.stack.leave_multicast_group( + crate::to_emb_addr(core::net::IpAddr::V6(multicast_addr)) + .ok_or(UdpError::UnsupportedProto)?, + )?; + } + + #[cfg(not(feature = "multicast"))] + { + Err(UdpError::UnsupportedProto)?; + } Ok(()) } @@ -252,8 +305,12 @@ pub enum UdpError { Recv(RecvError), Send(SendError), Bind(BindError), - Multicast(MulticastError), + /// The table of joined multicast groups is already full. + MulticastGroupTableFull, + /// Cannot join/leave the given multicast group. + MulticastUnaddressable, NoBuffers, + UnsupportedProto, } impl From for UdpError { @@ -274,9 +331,16 @@ impl From for UdpError { } } -impl From for UdpError { - fn from(e: MulticastError) -> Self { - UdpError::Multicast(e) +#[cfg(all( + feature = "multicast", + any(feature = "proto-ipv4", feature = "proto-ipv6") +))] +impl From for UdpError { + fn from(e: embassy_net::MulticastError) -> Self { + match e { + embassy_net::MulticastError::GroupTableFull => UdpError::MulticastGroupTableFull, + embassy_net::MulticastError::Unaddressable => UdpError::MulticastUnaddressable, + } } } @@ -287,8 +351,10 @@ impl embedded_io_async::Error for UdpError { UdpError::Recv(_) => ErrorKind::Other, UdpError::Send(_) => ErrorKind::Other, UdpError::Bind(_) => ErrorKind::Other, - UdpError::Multicast(_) => ErrorKind::Other, + UdpError::MulticastGroupTableFull => ErrorKind::Other, + UdpError::MulticastUnaddressable => ErrorKind::Other, UdpError::NoBuffers => ErrorKind::OutOfMemory, + UdpError::UnsupportedProto => ErrorKind::InvalidInput, } } } diff --git a/edge-nal-std/src/lib.rs b/edge-nal-std/src/lib.rs index 0053faf..d6d7026 100644 --- a/edge-nal-std/src/lib.rs +++ b/edge-nal-std/src/lib.rs @@ -1,5 +1,7 @@ #![allow(async_fn_in_trait)] #![warn(clippy::large_futures)] +#![allow(clippy::uninlined_format_args)] +#![allow(unknown_lints)] use core::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}; use core::ops::Deref; diff --git a/edge-nal/src/lib.rs b/edge-nal/src/lib.rs index 993fd41..348e781 100644 --- a/edge-nal/src/lib.rs +++ b/edge-nal/src/lib.rs @@ -1,5 +1,7 @@ #![no_std] #![allow(async_fn_in_trait)] +#![allow(clippy::uninlined_format_args)] +#![allow(unknown_lints)] pub use multicast::*; pub use raw::*; diff --git a/edge-raw/CHANGELOG.md b/edge-raw/CHANGELOG.md index 5e43fe7..ab46190 100644 --- a/edge-raw/CHANGELOG.md +++ b/edge-raw/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [0.6.0] - 2025-05-29 * Optional `defmt` support via two new features (one has to specify one, or the other, or neither, but not both): * `log` - uses the `log` crate for all logging * `defmt` - uses the `defmt` crate for all logging, and implements `defmt::Format` for all library types that otherwise implement `Debug` and/or `Display` diff --git a/edge-raw/Cargo.toml b/edge-raw/Cargo.toml index a410152..3165eac 100644 --- a/edge-raw/Cargo.toml +++ b/edge-raw/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "edge-raw" -version = "0.5.0" +version = "0.6.0" edition = "2021" rust-version = "1.83" description = "Async + `no_std` + no-alloc implementation of IP and UDP packet creation and parsing" diff --git a/edge-raw/src/lib.rs b/edge-raw/src/lib.rs index 396978b..af0223e 100644 --- a/edge-raw/src/lib.rs +++ b/edge-raw/src/lib.rs @@ -1,6 +1,8 @@ #![cfg_attr(not(feature = "std"), no_std)] #![allow(async_fn_in_trait)] #![warn(clippy::large_futures)] +#![allow(clippy::uninlined_format_args)] +#![allow(unknown_lints)] use core::net::{Ipv4Addr, SocketAddrV4}; diff --git a/edge-ws/CHANGELOG.md b/edge-ws/CHANGELOG.md index 62f03f7..56ebdbc 100644 --- a/edge-ws/CHANGELOG.md +++ b/edge-ws/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [0.6.0] - 2025-05-29 * Optional `defmt` support via two new features (one has to specify one, or the other, or neither, but not both): * `log` - uses the `log` crate for all logging * `defmt` - uses the `defmt` crate for all logging, and implements `defmt::Format` for all library types that otherwise implement `Debug` and/or `Display` diff --git a/edge-ws/Cargo.toml b/edge-ws/Cargo.toml index ae8bfbe..17fcc83 100644 --- a/edge-ws/Cargo.toml +++ b/edge-ws/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "edge-ws" -version = "0.4.0" +version = "0.5.0" edition = "2021" rust-version = "1.77" description = "Async + `no_std` + no-alloc implementation of the Websockets protocol" diff --git a/edge-ws/src/lib.rs b/edge-ws/src/lib.rs index fb38ecb..42f81ca 100644 --- a/edge-ws/src/lib.rs +++ b/edge-ws/src/lib.rs @@ -1,6 +1,8 @@ #![cfg_attr(not(feature = "std"), no_std)] #![allow(async_fn_in_trait)] #![warn(clippy::large_futures)] +#![allow(clippy::uninlined_format_args)] +#![allow(unknown_lints)] pub type Fragmented = bool; pub type Final = bool;