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<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 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<Self, NetworkParseError>
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.
source§fn new_host(addr: IpAddr) -> Self
fn new_host(addr: IpAddr) -> Self
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 IntoIterator for IpCidr
impl IntoIterator for IpCidr
source§impl Ord for IpCidr
impl Ord for IpCidr
source§impl PartialOrd for IpCidr
impl PartialOrd for IpCidr
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
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)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)