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 fn decrement(&mut self) -> bool
pub fn decrement(&mut self) -> bool
decrements host part (without changing the network part); returns true on wrap around
sourcepub const fn previous(self) -> Option<Self>
pub const fn previous(self) -> Option<Self>
Returns previous address in network or None
if it was the first address in the network
sourcepub const fn overflowing_add(self, step: u128) -> (Self, bool)
pub const fn overflowing_add(self, step: u128) -> (Self, bool)
Find the nth host after the current one in the current network
Returned boolean indicates whether an overflow occured.
sourcepub const fn overflowing_sub(self, step: u128) -> (Self, bool)
pub const fn overflowing_sub(self, step: u128) -> (Self, bool)
Find the nth host before the current one in the current network
Returned boolean indicates whether an overflow occured.
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 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>
source§fn new_host(addr: IpAddr) -> Self
fn new_host(addr: IpAddr) -> Self
source§fn increment(&mut self) -> bool
fn increment(&mut self) -> bool
source§fn next(self) -> Option<Self>
fn next(self) -> Option<Self>
None
if it was the last address in the networksource§fn decrement(&mut self) -> bool
fn decrement(&mut self) -> bool
source§fn previous(self) -> Option<Self>
fn previous(self) -> Option<Self>
None
if it was the first address in the networksource§fn overflowing_add(self, step: u128) -> (Self, bool)
fn overflowing_add(self, step: u128) -> (Self, bool)
source§fn overflowing_sub(self, step: u128) -> (Self, bool)
fn overflowing_sub(self, step: u128) -> (Self, bool)
source§fn first_address(&self) -> IpAddr
fn first_address(&self) -> IpAddr
source§fn last_address(&self) -> IpAddr
fn last_address(&self) -> IpAddr
source§fn network_length(&self) -> u8
fn network_length(&self) -> u8
source§fn is_host_address(&self) -> bool
fn is_host_address(&self) -> bool
source§impl Ord for IpInet
impl Ord for IpInet
source§impl PartialOrd for IpInet
impl PartialOrd for IpInet
impl Copy for IpInet
impl Eq for IpInet
impl StructuralPartialEq for IpInet
Auto Trait Implementations§
impl Freeze for IpInet
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
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
)