aboutsummaryrefslogtreecommitdiff
path: root/embassy-net
diff options
context:
space:
mode:
authorskkeye <[email protected]>2025-02-09 02:11:15 -0500
committerUlf Lilleengen <[email protected]>2025-02-13 10:27:30 +0100
commitbdb1b812135b7cb22f65009242d5b61712e8e9d7 (patch)
treed0b0af875006b05eb38bf54408fb9feff745a2cc /embassy-net
parent38b5f8bd0afd9669e638b8d83210427d2d372a96 (diff)
fix: nightly fmt
Diffstat (limited to 'embassy-net')
-rw-r--r--embassy-net/src/icmp.rs33
-rw-r--r--embassy-net/src/lib.rs4
2 files changed, 19 insertions, 18 deletions
diff --git a/embassy-net/src/icmp.rs b/embassy-net/src/icmp.rs
index 4cce5db50..ba206a465 100644
--- a/embassy-net/src/icmp.rs
+++ b/embassy-net/src/icmp.rs
@@ -252,24 +252,24 @@ impl Drop for IcmpSocket<'_> {
252 252
253pub mod ping { 253pub mod ping {
254 //! Ping utilities. 254 //! Ping utilities.
255 //! 255 //!
256 //! This module allows for an easy ICMP Echo message interface used to 256 //! This module allows for an easy ICMP Echo message interface used to
257 //! ping devices with an [ICMP Socket](IcmpSocket). 257 //! ping devices with an [ICMP Socket](IcmpSocket).
258 //! 258 //!
259 //! ## Usage 259 //! ## Usage
260 //! 260 //!
261 //! ``` 261 //! ```
262 //! use core::net::Ipv4Addr; 262 //! use core::net::Ipv4Addr;
263 //! use core::str::FromStr; 263 //! use core::str::FromStr;
264 //! 264 //!
265 //! use embassy_net::icmp::ping::{PingManager, PingParams}; 265 //! use embassy_net::icmp::ping::{PingManager, PingParams};
266 //! use embassy_net::icmp::PacketMetadata; 266 //! use embassy_net::icmp::PacketMetadata;
267 //! 267 //!
268 //! let mut rx_buffer = [0; 256]; 268 //! let mut rx_buffer = [0; 256];
269 //! let mut tx_buffer = [0; 256]; 269 //! let mut tx_buffer = [0; 256];
270 //! let mut rx_meta = [PacketMetadata::EMPTY]; 270 //! let mut rx_meta = [PacketMetadata::EMPTY];
271 //! let mut tx_meta = [PacketMetadata::EMPTY]; 271 //! let mut tx_meta = [PacketMetadata::EMPTY];
272 //! 272 //!
273 //! let mut ping_manager = PingManager::new(stack, &mut rx_meta, &mut rx_buffer, &mut tx_meta, &mut tx_buffer); 273 //! let mut ping_manager = PingManager::new(stack, &mut rx_meta, &mut rx_buffer, &mut tx_meta, &mut tx_buffer);
274 //! let addr = "192.168.8.1"; 274 //! let addr = "192.168.8.1";
275 //! let mut ping_params = PingParams::new(Ipv4Addr::from_str(addr).unwrap()); 275 //! let mut ping_params = PingParams::new(Ipv4Addr::from_str(addr).unwrap());
@@ -280,16 +280,18 @@ pub mod ping {
280 //! }; 280 //! };
281 //! ``` 281 //! ```
282 282
283 use super::*;
284 use core::net::{IpAddr, Ipv6Addr}; 283 use core::net::{IpAddr, Ipv6Addr};
284
285 use embassy_time::{Duration, Instant, Timer, WithTimeout}; 285 use embassy_time::{Duration, Instant, Timer, WithTimeout};
286 286
287 use super::*;
288
287 /// Error returned by [`ping()`](PingManager::ping). 289 /// Error returned by [`ping()`](PingManager::ping).
288 #[derive(PartialEq, Eq, Clone, Copy, Debug)] 290 #[derive(PartialEq, Eq, Clone, Copy, Debug)]
289 #[cfg_attr(feature = "defmt", derive(defmt::Format))] 291 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
290 pub enum PingError { 292 pub enum PingError {
291 /// The target did not respond. 293 /// The target did not respond.
292 /// 294 ///
293 /// The packet was sent but the Reply packet has not been recieved 295 /// The packet was sent but the Reply packet has not been recieved
294 /// in the timeout set by [`set_timeout()`](PingParams::set_timeout). 296 /// in the timeout set by [`set_timeout()`](PingParams::set_timeout).
295 DestinationHostUnreachable, 297 DestinationHostUnreachable,
@@ -339,7 +341,7 @@ pub mod ping {
339 impl<'d> PingManager<'d> { 341 impl<'d> PingManager<'d> {
340 /// Creates a new instance of [`PingManager`] with a [`Stack`] instance 342 /// Creates a new instance of [`PingManager`] with a [`Stack`] instance
341 /// and the buffers used for RX and TX. 343 /// and the buffers used for RX and TX.
342 /// 344 ///
343 /// **note**: This does not yet creates the ICMP socket. 345 /// **note**: This does not yet creates the ICMP socket.
344 pub fn new( 346 pub fn new(
345 stack: Stack<'d>, 347 stack: Stack<'d>,
@@ -387,7 +389,7 @@ pub mod ping {
387 // Make sure each ping takes at least 1 second to respect standards 389 // Make sure each ping takes at least 1 second to respect standards
388 let rate_limit_start = Instant::now(); 390 let rate_limit_start = Instant::now();
389 391
390 // make a single ping 392 // make a single ping
391 // - shorts out errors 393 // - shorts out errors
392 // - select the ip version 394 // - select the ip version
393 let ping_duration = match params.target().unwrap() { 395 let ping_duration = match params.target().unwrap() {
@@ -564,7 +566,6 @@ pub mod ping {
564 } 566 }
565 } 567 }
566 568
567
568 /// Parameters for configuring the ping operation. 569 /// Parameters for configuring the ping operation.
569 /// 570 ///
570 /// This struct provides various configuration options for performing ICMP ping operations, 571 /// This struct provides various configuration options for performing ICMP ping operations,
@@ -653,7 +654,7 @@ pub mod ping {
653 } 654 }
654 655
655 /// Sets the hop limit that will be used by the socket with [`set_hop_limit()`](IcmpSocket::set_hop_limit). 656 /// Sets the hop limit that will be used by the socket with [`set_hop_limit()`](IcmpSocket::set_hop_limit).
656 /// 657 ///
657 /// **Note**: A hop limit of [`Some(0)`](Some()) is equivalent to a hop limit of [`None`]. 658 /// **Note**: A hop limit of [`Some(0)`](Some()) is equivalent to a hop limit of [`None`].
658 pub fn set_hop_limit(&mut self, hop_limit: Option<u8>) -> &mut Self { 659 pub fn set_hop_limit(&mut self, hop_limit: Option<u8>) -> &mut Self {
659 let mut hop_limit = hop_limit; 660 let mut hop_limit = hop_limit;
@@ -669,9 +670,9 @@ pub mod ping {
669 self.hop_limit 670 self.hop_limit
670 } 671 }
671 672
672 /// Sets the count used for specifying the number of pings done on one 673 /// Sets the count used for specifying the number of pings done on one
673 /// [`ping()`](PingManager::ping) call. 674 /// [`ping()`](PingManager::ping) call.
674 /// 675 ///
675 /// **Note**: A count of 0 will be set as 1. 676 /// **Note**: A count of 0 will be set as 1.
676 pub fn set_count(&mut self, count: u16) -> &mut Self { 677 pub fn set_count(&mut self, count: u16) -> &mut Self {
677 let mut count = count; 678 let mut count = count;
@@ -682,7 +683,7 @@ pub mod ping {
682 self 683 self
683 } 684 }
684 685
685 /// Retrieve the count used for specifying the number of pings done on one 686 /// Retrieve the count used for specifying the number of pings done on one
686 /// [`ping()`](PingManager::ping) call. 687 /// [`ping()`](PingManager::ping) call.
687 pub fn count(&self) -> u16 { 688 pub fn count(&self) -> u16 {
688 self.count 689 self.count
diff --git a/embassy-net/src/lib.rs b/embassy-net/src/lib.rs
index 1bb112252..693a39ed5 100644
--- a/embassy-net/src/lib.rs
+++ b/embassy-net/src/lib.rs
@@ -15,6 +15,8 @@ pub(crate) mod fmt;
15#[cfg(feature = "dns")] 15#[cfg(feature = "dns")]
16pub mod dns; 16pub mod dns;
17mod driver_util; 17mod driver_util;
18#[cfg(feature = "icmp")]
19pub mod icmp;
18#[cfg(feature = "raw")] 20#[cfg(feature = "raw")]
19pub mod raw; 21pub mod raw;
20#[cfg(feature = "tcp")] 22#[cfg(feature = "tcp")]
@@ -22,8 +24,6 @@ pub mod tcp;
22mod time; 24mod time;
23#[cfg(feature = "udp")] 25#[cfg(feature = "udp")]
24pub mod udp; 26pub mod udp;
25#[cfg(feature = "icmp")]
26pub mod icmp;
27 27
28use core::cell::RefCell; 28use core::cell::RefCell;
29use core::future::{poll_fn, Future}; 29use core::future::{poll_fn, Future};