Skip to content

Commit

Permalink
misc: Fix more clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
vpetrigo committed Aug 22, 2024
1 parent e2b0c98 commit cee5edd
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/async_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ use tokio::net::{lookup_host, ToSocketAddrs};
use no_std_net::{SocketAddr, ToSocketAddrs};

#[cfg(not(feature = "std"))]
#[allow(clippy::unused_async)]
async fn lookup_host<T>(host: T) -> Result<impl Iterator<Item = SocketAddr>>
where
T: ToSocketAddrs,
{
#[allow(unused_variables)]
host.to_socket_addrs().map_err(|e| {
#[cfg(feature = "log")]
debug!("ToScoketAddrs: {}", e);
debug!("ToSocketAddrs: {:?}", e);
Error::AddressResolve
})
}
Expand Down Expand Up @@ -54,6 +55,9 @@ pub trait NtpUdpSocket {
) -> impl core::future::Future<Output = Result<(usize, SocketAddr)>>;
}

/// # Errors
///
/// Will return `Err` if an SNTP request sending fails
pub async fn sntp_send_request<A, U, T>(
dest: A,
socket: &U,
Expand Down Expand Up @@ -91,6 +95,9 @@ async fn send_request<A: ToSocketAddrs + Send, U: NtpUdpSocket>(
}
}

/// # Errors
///
/// Will return `Err` if an SNTP response processing fails
pub async fn sntp_process_response<A, U, T>(
dest: A,
socket: &U,
Expand All @@ -105,7 +112,7 @@ where
let mut response_buf = RawNtpPacket::default();
let (response, src) = socket.recv_from(response_buf.0.as_mut()).await?;
context.timestamp_gen.init();
let recv_timestamp = get_ntp_timestamp(context.timestamp_gen);
let recv_timestamp = get_ntp_timestamp(&context.timestamp_gen);
#[cfg(feature = "log")]
debug!("Response: {}", response);

Expand All @@ -118,7 +125,7 @@ where
}
}

if response != core::mem::size_of::<NtpPacket>() {
if response != size_of::<NtpPacket>() {
return Err(Error::IncorrectPayload);
}

Expand All @@ -133,6 +140,9 @@ where
result
}

/// # Errors
///
/// Will return `Err` if an SNTP request cannot be sent or SNTP response fails
pub async fn get_time<A, U, T>(
pool_addrs: A,
socket: U,
Expand Down

0 comments on commit cee5edd

Please sign in to comment.