diff --git a/clippy.toml b/clippy.toml index f3c4fee..52df439 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1 +1 @@ -future-size-threshold = 200 +future-size-threshold = 300 diff --git a/edge-nal-embassy/src/dns.rs b/edge-nal-embassy/src/dns.rs index c27af8c..865ff6b 100644 --- a/edge-nal-embassy/src/dns.rs +++ b/edge-nal-embassy/src/dns.rs @@ -22,7 +22,7 @@ impl<'a> Dns<'a> { } } -impl<'a> edge_nal::Dns for Dns<'a> { +impl edge_nal::Dns for Dns<'_> { type Error = DnsError; async fn get_host_by_name( diff --git a/edge-nal-embassy/src/lib.rs b/edge-nal-embassy/src/lib.rs index 32db23e..5fdc7c8 100644 --- a/edge-nal-embassy/src/lib.rs +++ b/edge-nal-embassy/src/lib.rs @@ -25,6 +25,7 @@ pub(crate) struct Pool { impl Pool { #[allow(clippy::declare_interior_mutable_const)] const VALUE: Cell = Cell::new(false); + #[allow(clippy::declare_interior_mutable_const)] const UNINIT: UnsafeCell> = UnsafeCell::new(MaybeUninit::uninit()); const fn new() -> Self { diff --git a/edge-nal-embassy/src/tcp.rs b/edge-nal-embassy/src/tcp.rs index 594e97b..2575a68 100644 --- a/edge-nal-embassy/src/tcp.rs +++ b/edge-nal-embassy/src/tcp.rs @@ -31,8 +31,8 @@ impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> Tcp<'d, N, TX_S } } -impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpConnect - for Tcp<'d, N, TX_SZ, RX_SZ> +impl TcpConnect + for Tcp<'_, N, TX_SZ, RX_SZ> { type Error = TcpError; @@ -50,9 +50,7 @@ impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpConnect } } -impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpBind - for Tcp<'d, N, TX_SZ, RX_SZ> -{ +impl TcpBind for Tcp<'_, N, TX_SZ, RX_SZ> { type Error = TcpError; type Accept<'a> @@ -71,8 +69,8 @@ pub struct TcpAccept<'d, const N: usize, const TX_SZ: usize = 1024, const RX_SZ: local: SocketAddr, } -impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> edge_nal::TcpAccept - for TcpAccept<'d, N, TX_SZ, RX_SZ> +impl edge_nal::TcpAccept + for TcpAccept<'_, N, TX_SZ, RX_SZ> { type Error = TcpError; @@ -161,8 +159,8 @@ impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpSocket<'d, N } } -impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> Drop - for TcpSocket<'d, N, TX_SZ, RX_SZ> +impl Drop + for TcpSocket<'_, N, TX_SZ, RX_SZ> { fn drop(&mut self) { unsafe { @@ -172,22 +170,22 @@ impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> Drop } } -impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> ErrorType - for TcpSocket<'d, N, TX_SZ, RX_SZ> +impl ErrorType + for TcpSocket<'_, N, TX_SZ, RX_SZ> { type Error = TcpError; } -impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> Read - for TcpSocket<'d, N, TX_SZ, RX_SZ> +impl Read + for TcpSocket<'_, N, TX_SZ, RX_SZ> { async fn read(&mut self, buf: &mut [u8]) -> Result { Ok(self.socket.read(buf).await?) } } -impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> Write - for TcpSocket<'d, N, TX_SZ, RX_SZ> +impl Write + for TcpSocket<'_, N, TX_SZ, RX_SZ> { async fn write(&mut self, buf: &[u8]) -> Result { Ok(self.socket.write(buf).await?) @@ -200,16 +198,17 @@ impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> Write } } -impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> Readable - for TcpSocket<'d, N, TX_SZ, RX_SZ> +impl Readable + for TcpSocket<'_, N, TX_SZ, RX_SZ> { async fn readable(&mut self) -> Result<(), Self::Error> { - Ok(self.socket.wait_read_ready().await) + self.socket.wait_read_ready().await; + Ok(()) } } -impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpShutdown - for TcpSocket<'d, N, TX_SZ, RX_SZ> +impl TcpShutdown + for TcpSocket<'_, N, TX_SZ, RX_SZ> { async fn close(&mut self, what: Close) -> Result<(), Self::Error> { TcpSocket::close(self, what).await @@ -224,19 +223,20 @@ impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpShutdown /// Implements the `Read` trait from `embedded-io-async` pub struct TcpSocketRead<'a>(TcpReader<'a>); -impl<'a> ErrorType for TcpSocketRead<'a> { +impl ErrorType for TcpSocketRead<'_> { type Error = TcpError; } -impl<'a> Read for TcpSocketRead<'a> { +impl Read for TcpSocketRead<'_> { async fn read(&mut self, buf: &mut [u8]) -> Result { self.0.read(buf).await.map_err(TcpError::from) } } -impl<'a> Readable for TcpSocketRead<'a> { +impl Readable for TcpSocketRead<'_> { async fn readable(&mut self) -> Result<(), Self::Error> { - Ok(self.0.wait_read_ready().await) + self.0.wait_read_ready().await; + Ok(()) } } @@ -244,11 +244,11 @@ impl<'a> Readable for TcpSocketRead<'a> { /// Implements the `Write` trait from `embedded-io-async` pub struct TcpSocketWrite<'a>(TcpWriter<'a>); -impl<'a> ErrorType for TcpSocketWrite<'a> { +impl ErrorType for TcpSocketWrite<'_> { type Error = TcpError; } -impl<'a> Write for TcpSocketWrite<'a> { +impl Write for TcpSocketWrite<'_> { async fn write(&mut self, buf: &[u8]) -> Result { self.0.write(buf).await.map_err(TcpError::from) } @@ -258,8 +258,8 @@ impl<'a> Write for TcpSocketWrite<'a> { } } -impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpSplit - for TcpSocket<'d, N, TX_SZ, RX_SZ> +impl TcpSplit + for TcpSocket<'_, N, TX_SZ, RX_SZ> { type Read<'a> = TcpSocketRead<'a> @@ -322,6 +322,14 @@ pub struct TcpBuffers { pool: Pool<([u8; TX_SZ], [u8; RX_SZ]), N>, } +impl Default + for TcpBuffers +{ + fn default() -> Self { + Self::new() + } +} + impl TcpBuffers { /// Create a new `TcpBuffers` instance pub const fn new() -> Self { diff --git a/edge-nal-embassy/src/udp.rs b/edge-nal-embassy/src/udp.rs index 3d106f6..5c5782b 100644 --- a/edge-nal-embassy/src/udp.rs +++ b/edge-nal-embassy/src/udp.rs @@ -36,8 +36,8 @@ impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> } } -impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> UdpBind - for Udp<'d, N, TX_SZ, RX_SZ, M> +impl UdpBind + for Udp<'_, N, TX_SZ, RX_SZ, M> { type Error = UdpError; @@ -93,8 +93,8 @@ impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> } } -impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> Drop - for UdpSocket<'d, N, TX_SZ, RX_SZ, M> +impl Drop + for UdpSocket<'_, N, TX_SZ, RX_SZ, M> { fn drop(&mut self) { unsafe { @@ -105,14 +105,14 @@ impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> } } -impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> ErrorType - for UdpSocket<'d, N, TX_SZ, RX_SZ, M> +impl ErrorType + for UdpSocket<'_, N, TX_SZ, RX_SZ, M> { type Error = UdpError; } -impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> UdpReceive - for UdpSocket<'d, N, TX_SZ, RX_SZ, M> +impl UdpReceive + for UdpSocket<'_, N, TX_SZ, RX_SZ, M> { async fn receive(&mut self, buffer: &mut [u8]) -> Result<(usize, SocketAddr), Self::Error> { let (len, remote_endpoint) = self.socket.recv_from(buffer).await?; @@ -121,8 +121,8 @@ impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> } } -impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> UdpSend - for UdpSocket<'d, N, TX_SZ, RX_SZ, M> +impl UdpSend + 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?; @@ -131,14 +131,14 @@ impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> } } -impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> ErrorType - for &UdpSocket<'d, N, TX_SZ, RX_SZ, M> +impl ErrorType + for &UdpSocket<'_, N, TX_SZ, RX_SZ, M> { type Error = UdpError; } -impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> UdpReceive - for &UdpSocket<'d, N, TX_SZ, RX_SZ, M> +impl UdpReceive + for &UdpSocket<'_, N, TX_SZ, RX_SZ, M> { async fn receive(&mut self, buffer: &mut [u8]) -> Result<(usize, SocketAddr), Self::Error> { let (len, remote_endpoint) = self.socket.recv_from(buffer).await?; @@ -147,8 +147,8 @@ impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> } } -impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> UdpSend - for &UdpSocket<'d, N, TX_SZ, RX_SZ, M> +impl UdpSend + 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?; @@ -157,16 +157,17 @@ impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> } } -impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> Readable - for &UdpSocket<'d, N, TX_SZ, RX_SZ, M> +impl Readable + for &UdpSocket<'_, N, TX_SZ, RX_SZ, M> { async fn readable(&mut self) -> Result<(), Self::Error> { - Ok(self.socket.wait_recv_ready().await) + self.socket.wait_recv_ready().await; + Ok(()) } } -impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> UdpSplit - for UdpSocket<'d, N, TX_SZ, RX_SZ, M> +impl UdpSplit + for UdpSocket<'_, N, TX_SZ, RX_SZ, M> { type Receive<'a> = &'a Self @@ -183,8 +184,8 @@ impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> } } -impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> MulticastV4 - for UdpSocket<'d, N, TX_SZ, RX_SZ, M> +impl MulticastV4 + for UdpSocket<'_, N, TX_SZ, RX_SZ, M> { async fn join_v4( &mut self, @@ -209,8 +210,8 @@ impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> } } -impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> MulticastV6 - for UdpSocket<'d, N, TX_SZ, RX_SZ, M> +impl MulticastV6 + for UdpSocket<'_, N, TX_SZ, RX_SZ, M> { async fn join_v6( &mut self, @@ -229,11 +230,12 @@ impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> } } -impl<'d, const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> Readable - for UdpSocket<'d, N, TX_SZ, RX_SZ, M> +impl Readable + for UdpSocket<'_, N, TX_SZ, RX_SZ, M> { async fn readable(&mut self) -> Result<(), Self::Error> { - Ok(self.socket.wait_recv_ready().await) + self.socket.wait_recv_ready().await; + Ok(()) } } @@ -296,6 +298,14 @@ pub struct UdpBuffers, } +impl Default + for UdpBuffers +{ + fn default() -> Self { + Self::new() + } +} + impl UdpBuffers {