[][src]Trait cidr::Inet

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; fn is_host_address(&self) -> 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 Address

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

type Cidr: Cidr<Address = Self::Address>

Corresponding Cidr type (representing only the network)

Loading content...

Required methods

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.

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

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

fn next(&mut self) -> bool

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

fn network(&self) -> Self::Cidr

network (i.e. drops the host information)

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

the host

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

first address in the network as plain address

fn first(&self) -> Self

first address in the network

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

last address in the network as plain address

fn last(&self) -> Self

last address in the network

fn network_length(&self) -> u8

length in bits of the shared prefix of the contained addresses

fn family(&self) -> Family

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

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.

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

check whether an address is contained in the network

Loading content...

Provided methods

fn is_host_address(&self) -> bool

whether network represents a single host address

Loading content...

Implementors

impl Inet for IpInet[src]

type Address = IpAddr

type Cidr = IpCidr

impl Inet for Ipv4Inet[src]

type Address = Ipv4Addr

type Cidr = Ipv4Cidr

impl Inet for Ipv6Inet[src]

type Address = Ipv6Addr

type Cidr = Ipv6Cidr

Loading content...