Trait cidr::Inet

source ·
pub trait Inet: Copy + Debug + Ord + Hash + PrivInet {
    type Address: Address<Inet = Self>;

Show 15 methods // Required methods fn new( addr: Self::Address, len: u8 ) -> Result<Self, NetworkLengthTooLongError>; fn new_host(addr: Self::Address) -> Self; fn increment(&mut self) -> bool; fn next(self) -> Option<Self>; fn network(&self) -> <Self::Address as Address>::Cidr; fn address(&self) -> Self::Address; fn first_address(&self) -> Self::Address; fn first(&self) -> Self; fn last_address(&self) -> Self::Address; fn last(&self) -> Self; fn network_length(&self) -> u8; fn family(&self) -> Family; fn is_host_address(&self) -> bool; fn mask(&self) -> Self::Address; fn contains(&self, addr: &Self::Address) -> bool;
}
Expand description

Types implementing Inet represent IP hosts within networks.

In addition to the network represented by the corresponding Cidr type, an Inet type also stores a single host address which is part of the network.

The host address is not really stored as separate data, but is stored together with the network address.

The representation of a Inet type is similar to that of the corresponding Cidr type, but uses the host address instead of the first address of the network.

Required Associated Types§

source

type Address: Address<Inet = Self>

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

Required Methods§

source

fn new(addr: Self::Address, len: u8) -> Result<Self, NetworkLengthTooLongError>

Create new host within a network from address and prefix length. If the network length exceeds the address length an error is returned.

source

fn new_host(addr: Self::Address) -> Self

Create a network containing a single address as host and the network (network length = address length).

source

fn increment(&mut self) -> bool

increments host part (without changing the network part); returns true on wrap around

source

fn next(self) -> Option<Self>

Returns next address in network or None if it was the last address in the network

source

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

network (i.e. drops the host information)

source

fn address(&self) -> Self::Address

the host

source

fn first_address(&self) -> Self::Address

first address in the network as plain address

source

fn first(&self) -> Self

first address in the network

source

fn last_address(&self) -> Self::Address

last address in the network as plain address

source

fn last(&self) -> Self

last address in the network

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 is_host_address(&self) -> bool

whether network represents a single host address

source

fn mask(&self) -> Self::Address

network mask: an pseudo address which has the first network length bits set to 1 and the remaining to 0.

source

fn contains(&self, addr: &Self::Address) -> bool

check whether an address is contained in the network

Implementors§