pub struct IpNet { /* private fields */ }Expand description
A CIDR range such as 10.0.0.0/8 or fd00::/8.
Implementations§
Source§impl IpNet
impl IpNet
Sourcepub fn new(addr: IpAddr, prefix: u8) -> Result<Self, ParseIpNetError>
pub fn new(addr: IpAddr, prefix: u8) -> Result<Self, ParseIpNetError>
prefix is bits of the network part: at most 32 for IPv4, 128 for IPv6.
pub fn addr(&self) -> IpAddr
pub fn prefix(&self) -> u8
Sourcepub fn contains(&self, ip: &IpAddr) -> bool
pub fn contains(&self, ip: &IpAddr) -> bool
True when ip is in the range. Families must match; use embedded_v4 first to
test an IPv6 form against an IPv4 range.
Trait Implementations§
impl Copy for IpNet
impl Eq for IpNet
impl StructuralPartialEq for IpNet
Auto Trait Implementations§
impl Freeze for IpNet
impl RefUnwindSafe for IpNet
impl Send for IpNet
impl Sync for IpNet
impl Unpin for IpNet
impl UnsafeUnpin for IpNet
impl UnwindSafe for IpNet
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