Types implementing Cidr represent IP networks. An IP network in
this case is a set of IP addresses which share a common prefix (when
viewed as a bitstring). The length of this prefix is called
In the standard representation the network is identified by the first address and the network length, separated by a '/'.
The parsers will expect the input in the same format, i.e. only the first address of the network is accepted.
The first network length bits in an address representing the network are the network part, the remaining bits are the host part. Requiring an address to be the first in a network is equivalent to requiring the host part being zero.
Type for the underlying address (
Inet type (representing an address + a network
fn new(addr: Self::Address, len: u8) -> Result<Self, NetworkParseError>
Create new network from address and prefix length. If the network length exceeds the address length or the address is not the first address in the network ("host part not zero") an error is returned.
Create a network containing a single address (network length = address length).
fn first_address(&self) -> Self::Address
first address in the network as plain address
first address in the network
fn last_address(&self) -> Self::Address
last address in the network as plain address
last address in the network
fn network_length(&self) -> u8
length in bits of the shared prefix of the contained addresses
IP family of the contained address (
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
fn iter(&self) -> InetIterator<Self::Inet>ⓘ
Iterate over all addresses in the range. With IPv6 addresses this can produce really long iterations (up to 2128 addresses).
fn is_host_address(&self) -> bool
whether network represents a single host address