pub struct PingParams<'a> { /* private fields */ }
Expand description
Parameters for configuring the ping operation.
This struct provides various configuration options for performing ICMP ping operations, including the target IP address, payload data, hop limit, number of pings, and timeout duration.
§Fields
target
- The target IP address for the ping operation.source
- The source IP address for the ping operation (IPv6 only).payload
- The data to be sent in the payload field of the ping.hop_limit
- The hop limit to be used by the socket.count
- The number of pings to be sent in one ping operation.timeout
- The timeout duration before returning aPingError::DestinationHostUnreachable
error.rate_limit
- The minimum time per echo request.
Implementations§
Source§impl<'a> PingParams<'a>
impl<'a> PingParams<'a>
Sourcepub fn new<T: Into<IpAddr>>(target: T) -> Self
pub fn new<T: Into<IpAddr>>(target: T) -> Self
Creates a new instance of PingParams
with the specified target IP address.
Sourcepub fn set_target<T: Into<IpAddr>>(&mut self, target: T) -> &mut Self
pub fn set_target<T: Into<IpAddr>>(&mut self, target: T) -> &mut Self
Sets the target IP address for the ping.
Sourcepub fn set_source<T: Into<Ipv6Address>>(&mut self, source: T) -> &mut Self
pub fn set_source<T: Into<Ipv6Address>>(&mut self, source: T) -> &mut Self
Sets the source IP address for the ping (IPv6 only).
Sourcepub fn source(&self) -> Option<Ipv6Addr>
pub fn source(&self) -> Option<Ipv6Addr>
Retrieves the source IP address for the ping (IPv6 only).
Sourcepub fn set_payload(&mut self, payload: &'a [u8]) -> &mut Self
pub fn set_payload(&mut self, payload: &'a [u8]) -> &mut Self
Sets the data used in the payload field of the ping with the provided slice.
Sourcepub fn payload(&self) -> &'a [u8]
pub fn payload(&self) -> &'a [u8]
Gives a reference to the slice of data that’s going to be sent in the payload field of the ping.
Sourcepub fn set_hop_limit(&mut self, hop_limit: Option<u8>) -> &mut Self
pub fn set_hop_limit(&mut self, hop_limit: Option<u8>) -> &mut Self
Sets the hop limit that will be used by the socket with set_hop_limit()
.
Note: A hop limit of Some(0)
is equivalent to a hop limit of None
.
Sourcepub fn hop_limit(&self) -> Option<u8>
pub fn hop_limit(&self) -> Option<u8>
Retrieves the hop limit that will be used by the socket with set_hop_limit()
.
Sourcepub fn set_count(&mut self, count: u16) -> &mut Self
pub fn set_count(&mut self, count: u16) -> &mut Self
Sets the count used for specifying the number of pings done on one
ping()
call.
Note: A count of 0 will be set as 1.
Sourcepub fn count(&self) -> u16
pub fn count(&self) -> u16
Retrieve the count used for specifying the number of pings done on one
ping()
call.
Sourcepub fn set_timeout(&mut self, timeout: Duration) -> &mut Self
pub fn set_timeout(&mut self, timeout: Duration) -> &mut Self
Sets the timeout used before returning PingError::DestinationHostUnreachable
when waiting for the Echo Reply icmp packet.
Sourcepub fn timeout(&self) -> Duration
pub fn timeout(&self) -> Duration
Retrieve the timeout used before returning PingError::DestinationHostUnreachable
when waiting for the Echo Reply icmp packet.
Sourcepub fn set_rate_limit(&mut self, rate_limit: Duration) -> &mut Self
pub fn set_rate_limit(&mut self, rate_limit: Duration) -> &mut Self
Sets the rate_limit
: minimum time per echo request.
Sourcepub fn rate_limit(&self) -> Duration
pub fn rate_limit(&self) -> Duration
Retrieve the rate_limit.