pub struct IpRules { /* private fields */ }Expand description
IpRules stores pre-parsed IP addresses and networks for efficient access control.
Implementations§
Source§impl IpRules
impl IpRules
Sourcepub fn new<T: AsRef<str>>(values: &[T]) -> Self
pub fn new<T: AsRef<str>>(values: &[T]) -> Self
Creates a new IpRules instance from a list of IP addresses and/or CIDR networks.
The input values are parsed and stored in optimized data structures for fast lookups. Invalid entries are ignored and a warning is logged.
Sourcepub fn is_match(&self, ip: &str) -> Result<bool, AddrParseError>
pub fn is_match(&self, ip: &str) -> Result<bool, AddrParseError>
Checks if a given IP address matches any of the stored rules.
This is the primary method for checking access. It parses the string and then performs the efficient matching logic.
Sourcepub fn is_match_addr(&self, ip_addr: &IpAddr) -> bool
pub fn is_match_addr(&self, ip_addr: &IpAddr) -> bool
A more performant version of is_match that accepts a pre-parsed IpAddr.
This allows callers to avoid re-parsing the IP address if they already
have it in IpAddr form.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for IpRules
impl RefUnwindSafe for IpRules
impl Send for IpRules
impl Sync for IpRules
impl Unpin for IpRules
impl UnsafeUnpin for IpRules
impl UnwindSafe for IpRules
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