pub enum IpInet {
V4(Ipv4Inet),
V6(Ipv6Inet),
}
Expand description
Inet
type representing either an IPv4 or an IPv6 host within a
network
Variants§
Implementations§
source§impl IpInet
impl IpInet
sourcepub const fn new(
addr: IpAddr,
len: u8
) -> Result<Self, NetworkLengthTooLongError>
pub const fn new( addr: IpAddr, len: u8 ) -> Result<Self, NetworkLengthTooLongError>
Create new host within a network from address and prefix length. If the network length exceeds the address length 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 as host and the network (network length = address length).
sourcepub fn increment(&mut self) -> bool
pub fn increment(&mut self) -> bool
increments host part (without changing the network part); returns true on wrap around
sourcepub const fn next(self) -> Option<Self>
pub const fn next(self) -> Option<Self>
Returns next address in network or None
if it was the last address in the network
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<'de> Deserialize<'de> for IpInet
Available on crate feature serde
only.
impl<'de> Deserialize<'de> for IpInet
Available on crate feature
serde
only.source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl FromStr for IpInet
impl FromStr for IpInet
§type Err = NetworkParseError
type Err = NetworkParseError
The associated error which can be returned from parsing.
source§impl Inet for IpInet
impl Inet for IpInet
source§fn new(addr: IpAddr, len: u8) -> Result<Self, NetworkLengthTooLongError>
fn new(addr: IpAddr, len: u8) -> Result<Self, NetworkLengthTooLongError>
Create new host within a network from address and prefix length.
If the network length exceeds the address length an error is
returned.
source§fn new_host(addr: IpAddr) -> Self
fn new_host(addr: IpAddr) -> Self
Create a network containing a single address as host and the
network (network length = address length).
source§fn increment(&mut self) -> bool
fn increment(&mut self) -> bool
increments host part (without changing the network part);
returns true on wrap around
source§fn next(self) -> Option<Self>
fn next(self) -> Option<Self>
Returns next address in network or
None
if it was the last address in the networksource§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 Ord for IpInet
impl Ord for IpInet
source§impl PartialEq<IpInet> for IpInet
impl PartialEq<IpInet> for IpInet
source§impl PartialOrd<IpInet> for IpInet
impl PartialOrd<IpInet> for IpInet
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 moreimpl Copy for IpInet
impl Eq for IpInet
impl StructuralEq for IpInet
impl StructuralPartialEq for IpInet
Auto Trait Implementations§
impl RefUnwindSafe for IpInet
impl Send for IpInet
impl Sync for IpInet
impl Unpin for IpInet
impl UnwindSafe for IpInet
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