pub enum AnyIpCidr {
Any,
V4(Ipv4Cidr),
V6(Ipv6Cidr),
}
Expand description
Represents either an IPv4 or an IPv6 network or “any”.
Allows for a bit string representation which treats “any” as the
empty string, IPv4 as starting with false
and IPv6 as starting
with true
. After the first bit the normal represenation for the
picked address-family follows.
Setting the first bit (using the bitstring
API) always truncates
the bit string to length 1 (i.e. /0
in the resulting family).
The Cidr
trait cannot be implemented for this type.
Variants§
Any
“any” network containing all IPv4 and IPv6 addresses
V4(Ipv4Cidr)
IPv4 network
V6(Ipv6Cidr)
IPv6 network
Implementations§
Source§impl AnyIpCidr
impl AnyIpCidr
Sourcepub const fn new(addr: IpAddr, len: u8) -> Result<Self, NetworkParseError>
pub const fn new(addr: IpAddr, 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.
Sourcepub const fn new_host(addr: IpAddr) -> Self
pub const fn new_host(addr: IpAddr) -> Self
Create a network containing a single address (network length = address length).
Sourcepub const fn first_address(&self) -> Option<IpAddr>
pub const fn first_address(&self) -> Option<IpAddr>
Sourcepub const fn last_address(&self) -> Option<IpAddr>
pub const fn last_address(&self) -> Option<IpAddr>
Sourcepub const fn network_length(&self) -> Option<u8>
pub const fn network_length(&self) -> Option<u8>
Sourcepub const fn is_host_address(&self) -> bool
pub const fn is_host_address(&self) -> bool
whether network represents a single host address