pub struct Pinger { /* private fields */ }Expand description
A Ping struct represents the state of one particular ping instance.
Implementations§
Source§impl Pinger
impl Pinger
Sourcepub fn new(host: IpAddr) -> Result<Pinger, Error>
pub fn new(host: IpAddr) -> Result<Pinger, Error>
Creates a new raw-socket ping instance from IpAddr.
Sourcepub fn with_socket_type(
host: IpAddr,
socket_type: SocketType,
) -> Result<Pinger, Error>
pub fn with_socket_type( host: IpAddr, socket_type: SocketType, ) -> Result<Pinger, Error>
Creates a new ping instance using a specific socket type.
Sourcepub fn socket_type(
&mut self,
socket_type: SocketType,
) -> Result<&mut Pinger, Error>
pub fn socket_type( &mut self, socket_type: SocketType, ) -> Result<&mut Pinger, Error>
Changes the socket type and recreates the underlying socket.
Sourcepub fn active_socket_type(&self) -> SocketType
pub fn active_socket_type(&self) -> SocketType
Returns the active socket type.
Sourcepub fn bind_device(
&mut self,
interface: Option<&[u8]>,
) -> Result<&mut Pinger, Error>
pub fn bind_device( &mut self, interface: Option<&[u8]>, ) -> Result<&mut Pinger, Error>
Sets the value for the SO_BINDTODEVICE option on this socket.
If a socket is bound to an interface, only packets received from that
particular interface are processed by the socket. Note that this only
works for some socket types, particularly AF_INET sockets.
If interface is None or an empty string it removes the binding.
This function is only available on Fuchsia and Linux.
Sourcepub fn size(&mut self, size: usize) -> &mut Pinger
pub fn size(&mut self, size: usize) -> &mut Pinger
Set the packet payload size in bytes. (default: 56)
Sourcepub fn timeout(&mut self, timeout: Duration) -> &mut Pinger
pub fn timeout(&mut self, timeout: Duration) -> &mut Pinger
Set the timeout of each ping. (default: 2s)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Pinger
impl !RefUnwindSafe for Pinger
impl Send for Pinger
impl Sync for Pinger
impl Unpin for Pinger
impl UnsafeUnpin for Pinger
impl !UnwindSafe for Pinger
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more