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§
Required Methods§
sourcefn new(addr: Self::Address, len: u8) -> Result<Self, NetworkLengthTooLongError>
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.
sourcefn new_host(addr: Self::Address) -> Self
fn new_host(addr: Self::Address) -> Self
Create a network containing a single address as host and the network (network length = address length).
sourcefn increment(&mut self) -> bool
fn increment(&mut self) -> bool
increments host part (without changing the network part); returns true on wrap around
sourcefn next(self) -> Option<Self>
fn next(self) -> Option<Self>
Returns next address in network or None
if it was the last address in the network
sourcefn network(&self) -> <Self::Address as Address>::Cidr
fn network(&self) -> <Self::Address as Address>::Cidr
network (i.e. drops the host information)
sourcefn first_address(&self) -> Self::Address
fn first_address(&self) -> Self::Address
first address in the network as plain address
sourcefn last_address(&self) -> Self::Address
fn last_address(&self) -> Self::Address
last address in the network as plain address
sourcefn network_length(&self) -> u8
fn network_length(&self) -> u8
length in bits of the shared prefix of the contained addresses
sourcefn is_host_address(&self) -> bool
fn is_host_address(&self) -> bool
whether network represents a single host address