Trait cidr::Inet [] [src]

pub trait Inet: Sized {
    type Address;
    type Cidr: Cidr<Address = Self::Address>;
    fn new(
        addr: Self::Address,
        len: u8
    ) -> Result<Self, NetworkLengthTooLongError>;
fn new_host(addr: Self::Address) -> Self;
fn next(&mut self) -> bool;
fn network(&self) -> Self::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 mask(&self) -> Self::Address;
fn contains(&self, addr: &Self::Address) -> bool; }

Types implementing Inet represent IP hosts within networks.

In addition to a network represented by the corresponding Cidr type, a 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 shows the host address instead of the first address of the network.

Associated Types

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

Corresponding Cidr type (representing only the network)

Required Methods

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

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

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

network (i.e. drops the host information)

the host

first address in the network as plain address

first address in the network

last address in the network as plain address

last address in the network

length in bits of the shared prefix of the contained addresses

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

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

check whether an address is contained in the network

Implementors