pub struct Ipv4Prefix {
pub addr: Ipv4Addr,
pub len: u8,
}Expand description
An IPv4 prefix (network address + prefix length).
Stored in canonical form: host bits are always zero.
Fields§
§addr: Ipv4AddrNetwork address (host bits zeroed).
len: u8Prefix length in bits (0–32).
Implementations§
Source§impl Ipv4Prefix
impl Ipv4Prefix
Sourcepub fn new(addr: Ipv4Addr, len: u8) -> Self
pub fn new(addr: Ipv4Addr, len: u8) -> Self
Create a new prefix, masking off host bits.
Prefix length is clamped to 32 (values above 32 are silently reduced). This is intentional: wire decoders validate prefix lengths before construction, and clamping is safer than panicking for internal callers that may compute lengths arithmetically.
Trait Implementations§
Source§impl Clone for Ipv4Prefix
impl Clone for Ipv4Prefix
Source§fn clone(&self) -> Ipv4Prefix
fn clone(&self) -> Ipv4Prefix
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Ipv4Prefix
impl Debug for Ipv4Prefix
Source§impl Display for Ipv4Prefix
impl Display for Ipv4Prefix
Source§impl Hash for Ipv4Prefix
impl Hash for Ipv4Prefix
Source§impl Ord for Ipv4Prefix
impl Ord for Ipv4Prefix
Source§fn cmp(&self, other: &Ipv4Prefix) -> Ordering
fn cmp(&self, other: &Ipv4Prefix) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for Ipv4Prefix
impl PartialEq for Ipv4Prefix
Source§impl PartialOrd for Ipv4Prefix
impl PartialOrd for Ipv4Prefix
impl Copy for Ipv4Prefix
impl Eq for Ipv4Prefix
impl StructuralPartialEq for Ipv4Prefix
Auto Trait Implementations§
impl Freeze for Ipv4Prefix
impl RefUnwindSafe for Ipv4Prefix
impl Send for Ipv4Prefix
impl Sync for Ipv4Prefix
impl Unpin for Ipv4Prefix
impl UnsafeUnpin for Ipv4Prefix
impl UnwindSafe for Ipv4Prefix
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