pub struct PingerBuilder { /* private fields */ }Expand description
Builder for a Pinger with socket level options.
let mut pinger = Pinger::builder()
.socket_type(SocketType::RAW)
.ident(1234)
.build()?;Implementations§
Source§impl PingerBuilder
impl PingerBuilder
Sourcepub fn socket_type(self, socket_type: SocketType) -> Self
pub fn socket_type(self, socket_type: SocketType) -> Self
Uses only the given socket type.
By default a datagram socket is tried first on Linux, Android and macOS, falling back to a raw socket, and the other way around on other platforms.
Sourcepub fn ident(self, ident: u16) -> Self
pub fn ident(self, ident: u16) -> Self
Sets the ICMP identifier. A random one is used by default.
On Linux datagram sockets the identifier is the port the socket is
bound to. Do not share an identifier between pingers there: depending
on the kernel, the first ping either fails with an Error::IoError,
or succeeds and replies are then delivered to only one of the pingers.
Sourcepub fn bind_device(self, device: impl Into<String>) -> Self
pub fn bind_device(self, device: impl Into<String>) -> Self
Binds the sockets to a network interface by name, such as "eth0".
Sourcepub fn mark(self, mark: u32) -> Self
pub fn mark(self, mark: u32) -> Self
Sets the SO_MARK (fwmark) of the sockets, used by policy routing.
Sourcepub fn build(self) -> Result<Pinger, Error>
pub fn build(self) -> Result<Pinger, Error>
Creates the pinger. Sockets are opened lazily by the first ping to each address family.
Sourcepub fn build_tokio(self) -> Result<Pinger, Error>
pub fn build_tokio(self) -> Result<Pinger, Error>
Creates an asynchronous tokio::Pinger with
the same options. Available with the tokio feature.
let mut pinger = Pinger::builder()
.socket_type(SocketType::RAW)
.build_tokio()?;