cidr

Trait InetPair

Source
pub trait InetPair:
    Copy
    + Debug
    + Eq
    + Hash
    + PrivInetPair {
    type Address: Address<InetPair = Self>;

    // Required methods
    fn new(
        first: <Self::Address as Address>::Inet,
        second: <Self::Address as Address>::Inet,
    ) -> Result<Self, InetTupleError>;
    fn new_from_addresses(
        first: Self::Address,
        second: Self::Address,
        len: u8,
    ) -> Result<Self, InetTupleError>;
    fn first(&self) -> <Self::Address as Address>::Inet;
    fn second(&self) -> <Self::Address as Address>::Inet;
    fn network(&self) -> <Self::Address as Address>::Cidr;
    fn network_length(&self) -> u8;
    fn family(&self) -> Family;
    fn iter(self) -> InetIterator<Self::Address> ;
}
Expand description

Pair of two addresses in the same network

Required Associated Types§

Source

type Address: Address<InetPair = Self>

Type for the underlying address (IpAddr, Ipv4Addr or Ipv6Addr).

Required Methods§

Source

fn new( first: <Self::Address as Address>::Inet, second: <Self::Address as Address>::Inet, ) -> Result<Self, InetTupleError>

Create new pair from two addresses in the same network

Fails if the addresses are not in the same network.

Source

fn new_from_addresses( first: Self::Address, second: Self::Address, len: u8, ) -> Result<Self, InetTupleError>

Create new pair from two addresses and a common length

Fails if the network length is invalid for the addresses or the addresses are not in the same network.

Source

fn first(&self) -> <Self::Address as Address>::Inet

First address

Source

fn second(&self) -> <Self::Address as Address>::Inet

Second address

Source

fn network(&self) -> <Self::Address as Address>::Cidr

network (i.e. drops the host information)

Source

fn network_length(&self) -> u8

length in bits of the shared prefix of the contained addresses

Source

fn family(&self) -> Family

IP family of the contained address (Ipv4 or Ipv6).

Source

fn iter(self) -> InetIterator<Self::Address>

Iterate over first..=second (inclusive)

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.

Implementors§