blob: ef2394f1b79d23ca848d2b107295afee8a5cda93 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#[cfg(target_os = "android")]
#[path = "android.rs"]
mod imp;
#[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]
#[path = "icmp.rs"]
mod imp;
pub use imp::Error;
/// Trait for sending ICMP requests to get some traffic from a remote server
pub trait Pinger: Send {
/// Sends an ICMP packet
fn send_icmp(&mut self) -> Result<(), Error>;
/// Clears all resources used by the pinger.
fn reset(&mut self) {}
}
/// Create a new pinger
pub fn new_pinger(
addr: std::net::Ipv4Addr,
#[cfg(any(target_os = "linux", target_os = "macos"))] interface_name: String,
) -> Result<Box<dyn Pinger>, Error> {
Ok(Box::new(imp::Pinger::new(
addr,
#[cfg(any(target_os = "linux", target_os = "macos"))]
interface_name,
)?))
}
|