Trait cidr::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)

Implementors§