pub struct Ipv4Inet { /* private fields */ }
Expand description
Inet
type representing an IPv4 host within a network
Derived ordering, i.e. first sort by address, then by network length.
Implementations§
source§impl Ipv4Inet
impl Ipv4Inet
sourcepub const fn new(
addr: Ipv4Addr,
len: u8,
) -> Result<Self, NetworkLengthTooLongError>
pub const fn new( addr: Ipv4Addr, 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: Ipv4Addr) -> Self
pub const fn new_host(addr: Ipv4Addr) -> 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) -> Ipv4Addr
pub const fn first_address(&self) -> Ipv4Addr
first address in the network as plain address
sourcepub const fn last_address(&self) -> Ipv4Addr
pub const fn last_address(&self) -> Ipv4Addr
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
source§impl Ipv4Inet
impl Ipv4Inet
sourcepub const fn overflowing_add_u32(self, step: u32) -> (Self, bool)
pub const fn overflowing_add_u32(self, step: u32) -> (Self, bool)
Find the nth host after the current one in the current network (32-bit IPv4 variant)
Returned boolean indicates whether an overflow occured.
sourcepub const fn overflowing_sub_u32(self, step: u32) -> (Self, bool)
pub const fn overflowing_sub_u32(self, step: u32) -> (Self, bool)
Find the nth host before the current one in the current network (32-bit IPv4 variant)
Returned boolean indicates whether an overflow occured.
Trait Implementations§
source§impl Inet for Ipv4Inet
impl Inet for Ipv4Inet
source§fn new(addr: Ipv4Addr, len: u8) -> Result<Self, NetworkLengthTooLongError>
fn new(addr: Ipv4Addr, len: u8) -> Result<Self, NetworkLengthTooLongError>
source§fn new_host(addr: Ipv4Addr) -> Self
fn new_host(addr: Ipv4Addr) -> 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) -> Ipv4Addr
fn first_address(&self) -> Ipv4Addr
source§fn last_address(&self) -> Ipv4Addr
fn last_address(&self) -> Ipv4Addr
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 Ipv4Inet
impl Ord for Ipv4Inet
source§impl PartialOrd for Ipv4Inet
impl PartialOrd for Ipv4Inet
impl Copy for Ipv4Inet
impl Eq for Ipv4Inet
impl StructuralPartialEq for Ipv4Inet
Auto Trait Implementations§
impl Freeze for Ipv4Inet
impl RefUnwindSafe for Ipv4Inet
impl Send for Ipv4Inet
impl Sync for Ipv4Inet
impl Unpin for Ipv4Inet
impl UnwindSafe for Ipv4Inet
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
)