Skip to content

Commit

Permalink
fix a bunch of clippy errors with latest nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmarkov committed Dec 11, 2024
1 parent a252419 commit c8b5c80
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 58 deletions.
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
future-size-threshold = 200
future-size-threshold = 300
2 changes: 1 addition & 1 deletion edge-nal-embassy/src/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions edge-nal-embassy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub(crate) struct Pool<T, const N: usize> {
impl<T, const N: usize> Pool<T, N> {
#[allow(clippy::declare_interior_mutable_const)]
const VALUE: Cell<bool> = Cell::new(false);
#[allow(clippy::declare_interior_mutable_const)]
const UNINIT: UnsafeCell<MaybeUninit<T>> = UnsafeCell::new(MaybeUninit::uninit());

const fn new() -> Self {
Expand Down
64 changes: 36 additions & 28 deletions edge-nal-embassy/src/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpConnect
for Tcp<'_, N, TX_SZ, RX_SZ>
{
type Error = TcpError;

Expand All @@ -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<const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpBind for Tcp<'_, N, TX_SZ, RX_SZ> {
type Error = TcpError;

type Accept<'a>
Expand All @@ -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<const N: usize, const TX_SZ: usize, const RX_SZ: usize> edge_nal::TcpAccept
for TcpAccept<'_, N, TX_SZ, RX_SZ>
{
type Error = TcpError;

Expand Down Expand Up @@ -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<const N: usize, const TX_SZ: usize, const RX_SZ: usize> Drop
for TcpSocket<'_, N, TX_SZ, RX_SZ>
{
fn drop(&mut self) {
unsafe {
Expand All @@ -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<const N: usize, const TX_SZ: usize, const RX_SZ: usize> 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<const N: usize, const TX_SZ: usize, const RX_SZ: usize> Read
for TcpSocket<'_, N, TX_SZ, RX_SZ>
{
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> {
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<const N: usize, const TX_SZ: usize, const RX_SZ: usize> Write
for TcpSocket<'_, N, TX_SZ, RX_SZ>
{
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
Ok(self.socket.write(buf).await?)
Expand All @@ -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<const N: usize, const TX_SZ: usize, const RX_SZ: usize> 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<const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpShutdown
for TcpSocket<'_, N, TX_SZ, RX_SZ>
{
async fn close(&mut self, what: Close) -> Result<(), Self::Error> {
TcpSocket::close(self, what).await
Expand All @@ -224,31 +223,32 @@ 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<usize, Self::Error> {
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(())
}
}

/// Represents the write half of a split TCP socket
/// 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<usize, Self::Error> {
self.0.write(buf).await.map_err(TcpError::from)
}
Expand All @@ -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<const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpSplit
for TcpSocket<'_, N, TX_SZ, RX_SZ>
{
type Read<'a>
= TcpSocketRead<'a>
Expand Down Expand Up @@ -322,6 +322,14 @@ pub struct TcpBuffers<const N: usize, const TX_SZ: usize, const RX_SZ: usize> {
pool: Pool<([u8; TX_SZ], [u8; RX_SZ]), N>,
}

impl<const N: usize, const TX_SZ: usize, const RX_SZ: usize> Default
for TcpBuffers<N, TX_SZ, RX_SZ>
{
fn default() -> Self {
Self::new()
}
}

impl<const N: usize, const TX_SZ: usize, const RX_SZ: usize> TcpBuffers<N, TX_SZ, RX_SZ> {
/// Create a new `TcpBuffers` instance
pub const fn new() -> Self {
Expand Down
66 changes: 38 additions & 28 deletions edge-nal-embassy/src/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> UdpBind
for Udp<'_, N, TX_SZ, RX_SZ, M>
{
type Error = UdpError;

Expand Down Expand Up @@ -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<const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> Drop
for UdpSocket<'_, N, TX_SZ, RX_SZ, M>
{
fn drop(&mut self) {
unsafe {
Expand All @@ -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<const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> 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<const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> 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?;
Expand All @@ -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<const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> 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?;
Expand All @@ -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<const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> 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<const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> 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?;
Expand All @@ -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<const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> 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?;
Expand All @@ -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<const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> 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<const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> UdpSplit
for UdpSocket<'_, N, TX_SZ, RX_SZ, M>
{
type Receive<'a>
= &'a Self
Expand All @@ -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<const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> MulticastV4
for UdpSocket<'_, N, TX_SZ, RX_SZ, M>
{
async fn join_v4(
&mut self,
Expand All @@ -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<const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> MulticastV6
for UdpSocket<'_, N, TX_SZ, RX_SZ, M>
{
async fn join_v6(
&mut self,
Expand All @@ -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<const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> 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(())
}
}

Expand Down Expand Up @@ -296,6 +298,14 @@ pub struct UdpBuffers<const N: usize, const TX_SZ: usize, const RX_SZ: usize, co
>,
}

impl<const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize> Default
for UdpBuffers<N, TX_SZ, RX_SZ, M>
{
fn default() -> Self {
Self::new()
}
}

impl<const N: usize, const TX_SZ: usize, const RX_SZ: usize, const M: usize>
UdpBuffers<N, TX_SZ, RX_SZ, M>
{
Expand Down

0 comments on commit c8b5c80

Please sign in to comment.