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§fn subset_cmp(&self, other: &Self) -> Option<Ordering>
fn subset_cmp(&self, other: &Self) -> Option<Ordering>
source§fn lexicographic_cmp(&self, other: &Self) -> Ordering
fn lexicographic_cmp(&self, other: &Self) -> Ordering
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 PartialOrd for AnyIpCidr
impl PartialOrd for AnyIpCidr
source§impl Serialize for AnyIpCidr
impl Serialize for AnyIpCidr
source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl Copy for AnyIpCidr
impl Eq for AnyIpCidr
impl StructuralPartialEq for AnyIpCidr
Auto Trait Implementations§
impl Freeze for AnyIpCidr
impl RefUnwindSafe for AnyIpCidr
impl Send for AnyIpCidr
impl Sync for AnyIpCidr
impl Unpin for AnyIpCidr
impl UnwindSafe for AnyIpCidr
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)