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<AnyIpCidr, NetworkParseError>
pub const fn new(addr: IpAddr, len: u8) -> Result<AnyIpCidr, 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) -> AnyIpCidr
pub const fn new_host(addr: IpAddr) -> AnyIpCidr
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
Trait Implementations§
source§impl BitString for AnyIpCidr
impl BitString for AnyIpCidr
source§impl<'de> Deserialize<'de> for AnyIpCidr
impl<'de> Deserialize<'de> for AnyIpCidr
source§fn deserialize<D>(
deserializer: D,
) -> Result<AnyIpCidr, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<AnyIpCidr, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
source§impl Ord for AnyIpCidr
impl Ord for AnyIpCidr
source§impl PartialEq for AnyIpCidr
impl PartialEq for AnyIpCidr
source§impl PartialOrd for AnyIpCidr
impl PartialOrd for AnyIpCidr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more