fix: nightly fmt

This commit is contained in:
skkeye 2025-02-09 02:11:15 -05:00 committed by Ulf Lilleengen
parent 38b5f8bd0a
commit bdb1b81213
4 changed files with 34 additions and 32 deletions

View File

@ -280,10 +280,12 @@ pub mod ping {
//! }; //! };
//! ``` //! ```
use super::*;
use core::net::{IpAddr, Ipv6Addr}; use core::net::{IpAddr, Ipv6Addr};
use embassy_time::{Duration, Instant, Timer, WithTimeout}; use embassy_time::{Duration, Instant, Timer, WithTimeout};
use super::*;
/// Error returned by [`ping()`](PingManager::ping). /// Error returned by [`ping()`](PingManager::ping).
#[derive(PartialEq, Eq, Clone, Copy, Debug)] #[derive(PartialEq, Eq, Clone, Copy, Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))] #[cfg_attr(feature = "defmt", derive(defmt::Format))]
@ -564,7 +566,6 @@ pub mod ping {
} }
} }
/// Parameters for configuring the ping operation. /// Parameters for configuring the ping operation.
/// ///
/// This struct provides various configuration options for performing ICMP ping operations, /// This struct provides various configuration options for performing ICMP ping operations,

View File

@ -15,6 +15,8 @@ pub(crate) mod fmt;
#[cfg(feature = "dns")] #[cfg(feature = "dns")]
pub mod dns; pub mod dns;
mod driver_util; mod driver_util;
#[cfg(feature = "icmp")]
pub mod icmp;
#[cfg(feature = "raw")] #[cfg(feature = "raw")]
pub mod raw; pub mod raw;
#[cfg(feature = "tcp")] #[cfg(feature = "tcp")]
@ -22,8 +24,6 @@ pub mod tcp;
mod time; mod time;
#[cfg(feature = "udp")] #[cfg(feature = "udp")]
pub mod udp; pub mod udp;
#[cfg(feature = "icmp")]
pub mod icmp;
use core::cell::RefCell; use core::cell::RefCell;
use core::future::{poll_fn, Future}; use core::future::{poll_fn, Future};

View File

@ -106,16 +106,12 @@ async fn main(spawner: Spawner) {
// Send the packet and store the starting instant to mesure latency later // Send the packet and store the starting instant to mesure latency later
let start = socket let start = socket
.send_to_with( .send_to_with(icmp_repr.buffer_len(), cfg.gateway.unwrap(), |buf| {
icmp_repr.buffer_len(), // Create and populate the packet buffer allocated by `send_to_with`
cfg.gateway.unwrap(), let mut icmp_packet = Icmpv4Packet::new_unchecked(buf);
|buf| { icmp_repr.emit(&mut icmp_packet, &ChecksumCapabilities::default());
// Create and populate the packet buffer allocated by `send_to_with` Instant::now() // Return the instant where the packet was sent
let mut icmp_packet = Icmpv4Packet::new_unchecked(buf); })
icmp_repr.emit(&mut icmp_packet, &ChecksumCapabilities::default());
Instant::now() // Return the instant where the packet was sent
},
)
.await .await
.unwrap(); .unwrap();
@ -123,7 +119,12 @@ async fn main(spawner: Spawner) {
socket socket
.recv_with(|(buf, addr)| { .recv_with(|(buf, addr)| {
let packet = Icmpv4Packet::new_checked(buf).unwrap(); let packet = Icmpv4Packet::new_checked(buf).unwrap();
info!("Recieved {:?} from {} in {}ms", packet.data(), addr, start.elapsed().as_millis()); info!(
"Recieved {:?} from {} in {}ms",
packet.data(),
addr,
start.elapsed().as_millis()
);
}) })
.await .await
.unwrap(); .unwrap();

View File

@ -100,7 +100,7 @@ async fn main(spawner: Spawner) {
// Create the ping manager instance // Create the ping manager instance
let mut ping_manager = PingManager::new(stack, &mut rx_meta, &mut rx_buffer, &mut tx_meta, &mut tx_buffer); let mut ping_manager = PingManager::new(stack, &mut rx_meta, &mut rx_buffer, &mut tx_meta, &mut tx_buffer);
let addr = "192.168.8.1"; // Address to ping to let addr = "192.168.8.1"; // Address to ping to
// Create the PingParams with the target address // Create the PingParams with the target address
let mut ping_params = PingParams::new(Ipv4Addr::from_str(addr).unwrap()); let mut ping_params = PingParams::new(Ipv4Addr::from_str(addr).unwrap());
// (optional) Set custom properties of the ping // (optional) Set custom properties of the ping
ping_params.set_payload(b"Hello, Ping!"); // custom payload ping_params.set_payload(b"Hello, Ping!"); // custom payload
@ -118,7 +118,7 @@ async fn main(spawner: Spawner) {
Ok(time) => { Ok(time) => {
info!("{} is online\n- latency: {}ms\n", ip_addr, time.as_millis()); info!("{} is online\n- latency: {}ms\n", ip_addr, time.as_millis());
total_online_hosts += 1; total_online_hosts += 1;
}, }
_ => continue, _ => continue,
} }
} }