cidr

Trait Inet

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

Show 19 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 decrement(&mut self) -> bool; fn previous(self) -> Option<Self>; fn overflowing_add(self, step: u128) -> (Self, bool); fn overflowing_sub(self, step: u128) -> (Self, bool); 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 decrement(&mut self) -> bool

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

Source

fn previous(self) -> Option<Self>

Returns previous address in network or None if it was the first address in the network

Source

fn overflowing_add(self, step: u128) -> (Self, bool)

Find the nth host after the current one in the current network

Returned boolean indicates whether an overflow occured.

Source

fn overflowing_sub(self, step: u128) -> (Self, bool)

Find the nth host before the current one in the current network

Returned boolean indicates whether an overflow occured.

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

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§