pub trait IcmpSocket {
type AddrType;
type PacketType;
// Required methods
fn set_timeout(&mut self, timeout: Option<Duration>);
fn set_max_hops(&mut self, hops: u32);
fn bind<A: Into<Self::AddrType>>(&mut self, addr: A) -> Result<()>;
fn send_to(
&mut self,
dest: Self::AddrType,
packet: Self::PacketType,
) -> Result<()>;
fn rcv_from(&mut self) -> Result<(Self::PacketType, SockAddr)>;
}
Expand description
Trait for an IcmpSocket implemented by Icmpv4Socket and Icmpv6Socket.
Required Associated Types§
Sourcetype PacketType
type PacketType
The type of packet this socket handles.
Required Methods§
Sourcefn set_timeout(&mut self, timeout: Option<Duration>)
fn set_timeout(&mut self, timeout: Option<Duration>)
Sets the timeout on the socket for rcv_from. A value of None will cause rcv_from to block.
Sourcefn set_max_hops(&mut self, hops: u32)
fn set_max_hops(&mut self, hops: u32)
Sets the ttl for packets sent on this socket. Controls the number of hops the packet will be allowed to traverse.
Sourcefn bind<A: Into<Self::AddrType>>(&mut self, addr: A) -> Result<()>
fn bind<A: Into<Self::AddrType>>(&mut self, addr: A) -> Result<()>
Binds this socket to an address.
Sourcefn send_to(
&mut self,
dest: Self::AddrType,
packet: Self::PacketType,
) -> Result<()>
fn send_to( &mut self, dest: Self::AddrType, packet: Self::PacketType, ) -> Result<()>
Sends the packet to the given destination.
Sourcefn rcv_from(&mut self) -> Result<(Self::PacketType, SockAddr)>
fn rcv_from(&mut self) -> Result<(Self::PacketType, SockAddr)>
Receive a packet on this socket.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.