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 PartialOrd for IpCidr
impl PartialOrd for IpCidr
source§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
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
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more