pub struct SocketPair {
pub ipv4: IcmpSocket<Icmpv4>,
pub ipv6: IcmpSocket<Icmpv6>,
}
Expand description
Holds both an IPv4 and IPv6 socket.
This is a quite simple wrapper. Access the pub
fields to send or receive when you know the IP
version to use at compile time. To send a message that supports both versions, see
SocketPair::send_to_either
, and to receive from either socket, see
SocketPair::recv_either
.
Fields§
§ipv4: IcmpSocket<Icmpv4>
The IPv4 socket
ipv6: IcmpSocket<Icmpv6>
The IPv6 socket
Implementations§
Source§impl SocketPair
impl SocketPair
Sourcepub fn new(
icmpv4_config: SocketConfig<Icmpv4>,
icmpv6_config: SocketConfig<Icmpv6>,
) -> Result<Self>
pub fn new( icmpv4_config: SocketConfig<Icmpv4>, icmpv6_config: SocketConfig<Icmpv6>, ) -> Result<Self>
Create a new SocketPair.
Sourcepub async fn send_to_either<M>(&self, msg: &mut M, addr: IpAddr) -> Result<()>
pub async fn send_to_either<M>(&self, msg: &mut M, addr: IpAddr) -> Result<()>
Send msg
to either the IPv4 or IPv6 sockets, per the IP version of addr
.
Sourcepub async fn recv_either<'a>(
&self,
ip_version: IpVersion,
buf: &'a mut [u8],
) -> Result<(&'a [u8], Range<usize>)>
pub async fn recv_either<'a>( &self, ip_version: IpVersion, buf: &'a mut [u8], ) -> Result<(&'a [u8], Range<usize>)>
Receive from the socket indicated by ip_version
.
This provides a convenient way to have a consistent Future
type that can represent
reading from either socket.
Sourcepub fn platform_echo_id(&self, ip_version: IpVersion) -> Option<EchoId>
pub fn platform_echo_id(&self, ip_version: IpVersion) -> Option<EchoId>
Like IcmpSocket::platform_echo_id
, but for whichever socket matches ip_version
.
Auto Trait Implementations§
impl Freeze for SocketPair
impl !RefUnwindSafe for SocketPair
impl Send for SocketPair
impl Sync for SocketPair
impl Unpin for SocketPair
impl !UnwindSafe for SocketPair
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