pub enum IpRange {
V4 {
base: Ipv4Addr,
prefix_len: u8,
},
V6 {
base: Ipv6Addr,
prefix_len: u8,
},
}Expand description
Represents a range of IP addresses to block
Variants§
V4
IPv4 range with CIDR notation (e.g., 192.168.0.0/16)
V6
IPv6 range with CIDR notation (e.g., 2001:db8::/32)
Implementations§
Source§impl IpRange
impl IpRange
Sourcepub fn from_cidr(cidr: &str) -> Result<Self, IpValidationError>
pub fn from_cidr(cidr: &str) -> Result<Self, IpValidationError>
Create a new IP range from a CIDR notation string
Sourcepub fn contains_ipv4(&self, ip: &Ipv4Addr) -> bool
pub fn contains_ipv4(&self, ip: &Ipv4Addr) -> bool
Check if this range contains the given IPv4 address
Sourcepub fn contains_ipv6(&self, ip: &Ipv6Addr) -> bool
pub fn contains_ipv6(&self, ip: &Ipv6Addr) -> bool
Check if this range contains the given IPv6 address
Trait Implementations§
impl StructuralPartialEq for IpRange
Auto Trait Implementations§
impl Freeze for IpRange
impl RefUnwindSafe for IpRange
impl Send for IpRange
impl Sync for IpRange
impl Unpin for IpRange
impl UnsafeUnpin for IpRange
impl UnwindSafe for IpRange
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