pub enum IpCidr {
V4(Ipv4Cidr),
V6(Ipv6Cidr),
}
Expand description
Cidr
type representing either an IPv4 or an IPv6 network
Variants§
Implementations§
source§impl IpCidr
impl IpCidr
sourcepub const fn new(addr: IpAddr, len: u8) -> Result<IpCidr, NetworkParseError>
pub const fn new(addr: IpAddr, len: u8) -> Result<IpCidr, 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) -> IpCidr
pub const fn new_host(addr: IpAddr) -> IpCidr
Create a network containing a single address (network length = address length).
sourcepub const fn iter(&self) -> InetIterator<IpAddr>
pub const fn iter(&self) -> InetIterator<IpAddr>
Iterate over all addresses in the range. With IPv6 addresses this can produce really long iterations (up to 2128 addresses).
sourcepub const fn first_address(&self) -> IpAddr
pub const fn first_address(&self) -> IpAddr
first address in the network as plain address
sourcepub const fn last_address(&self) -> IpAddr
pub const fn last_address(&self) -> IpAddr
last address in the network as plain address
sourcepub const fn network_length(&self) -> u8
pub const fn network_length(&self) -> u8
length in bits of the shared prefix of the contained addresses
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 Cidr for IpCidr
impl Cidr for IpCidr
source§fn new(addr: IpAddr, len: u8) -> Result<IpCidr, NetworkParseError>
fn new(addr: IpAddr, len: u8) -> Result<IpCidr, 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.
source§fn new_host(addr: IpAddr) -> IpCidr
fn new_host(addr: IpAddr) -> IpCidr
Create a network containing a single address (network length =
address length).
source§fn iter(&self) -> InetIterator<IpAddr>
fn iter(&self) -> InetIterator<IpAddr>
Iterate over all addresses in the range. With IPv6 addresses
this can produce really long iterations (up to 2128
addresses).
source§fn first_address(&self) -> IpAddr
fn first_address(&self) -> IpAddr
first address in the network as plain address
source§fn last_address(&self) -> IpAddr
fn last_address(&self) -> IpAddr
last address in the network as plain address
source§fn network_length(&self) -> u8
fn network_length(&self) -> u8
length in bits of the shared prefix of the contained addresses
source§fn is_host_address(&self) -> bool
fn is_host_address(&self) -> bool
whether network represents a single host address
source§impl<'de> Deserialize<'de> for IpCidr
impl<'de> Deserialize<'de> for IpCidr
source§fn deserialize<D>(
deserializer: D,
) -> Result<IpCidr, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<IpCidr, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl IntoIterator for IpCidr
impl IntoIterator for IpCidr
source§impl Ord for IpCidr
impl Ord for IpCidr
source§impl PartialEq for IpCidr
impl PartialEq for IpCidr
source§impl PartialOrd for IpCidr
impl PartialOrd for IpCidr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for IpCidr
impl Serialize for IpCidr
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,
Serialize this value into the given Serde serializer. Read more
impl Copy for IpCidr
impl Eq for IpCidr
impl StructuralPartialEq for IpCidr
Auto Trait Implementations§
impl Freeze for IpCidr
impl RefUnwindSafe for IpCidr
impl Send for IpCidr
impl Sync for IpCidr
impl Unpin for IpCidr
impl UnwindSafe for IpCidr
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
Mutably borrows from an owned value. Read more