Struct SocketPair

Source
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

Source

pub fn new( icmpv4_config: SocketConfig<Icmpv4>, icmpv6_config: SocketConfig<Icmpv6>, ) -> Result<Self>

Create a new SocketPair.

Source

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.

Source

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.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V